public Instru(string name, string addr, string remark, InstType type) { this.Name = name; this.Addr = addr; this.Remark = remark; this.Type = type; }
static Instrument Get(BinaryReaderEx br, InstType it) { Instrument s = new Instrument(); s.Read(br, it); return(s); }
public void Read(BinaryReaderEx br, InstType it) { instType = it; switch (it) { case InstType.Long: ReadLong(br); break; case InstType.Short: ReadShort(br); break; } }
private void SetContextInstType(InstType instType, RegistObjectContext context) { context.InstType = instType; context.InstCreator = InstCreatorFactory.Create(instType); var result = context.InstCreator.Check(context); if (result.IsPass == false) { throw new Exception("regist error:" + result.Message); } }
/// <summary> /// 注册 /// </summary> /// <param name="pType"></param> /// <param name="cType"></param> /// <param name="instType"></param> /// <param name="name"></param> public void Regist(Type pType, Type cType, InstType instType, string name) { Dictionary <string, RegistObjectContext> cDic = null; lock (dic) { if (string.IsNullOrEmpty(name)) { name = DEFAULTNAME; } try { cDic = dic[pType]; } catch (KeyNotFoundException) { dic.Add(pType, new Dictionary <string, RegistObjectContext>()); cDic = dic[pType]; } if (instType == InstType.Decorate) { throw new Exception(string.Format("Decorate Inst Not Allow Use Normal Regist Method To Regist")); } if (cDic.ContainsKey(name)) { throw new Exception(string.Format("Regist Type '{0}' Must be Unique", name)); } else { lock (cDic) { RegistObjectContext context = new RegistObjectContext(); context.ObjType = cType; context.PType = pType; this.SetContextInstType(instType, context); cDic.Add(name, context); } } } }
public override string ToString() { string instructionText = ""; if (InstType == InstructionType.PenUp || InstType == InstructionType.PenDown) { instructionText = InstType.ToString(); } else if (InstType == InstructionType.PenChange) { instructionText = "Pen change: " + NewPen; } else if (InstType == InstructionType.Delta) { instructionText = string.Format("Delta: DX {0}, DY {1}", X, Y); } else { instructionText = "Unknown instruction: " + InstType.ToString(); } return(instructionText); }
/// <summary> /// 注册 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="qType"></param> /// <param name="instType"></param> public void Regist <T>(Type qType, InstType instType) { this.Regist <T>(qType, instType, DEFAULTNAME); }
/// <summary> /// 注册 /// 不允许使用装饰者作为实例类型进行注册,否则会抛出异常 /// </summary> /// <typeparam name="T">基类或接口</typeparam> /// <typeparam name="Q">实现类</typeparam> /// <param name="instType">类实例化方式</param> /// <param name="name">注册对象</param> public void Regist <T, Q>(string name, InstType instType) where Q : T { this.Regist <T>(typeof(Q), instType, name); }
public static IInstCreator Create(InstType instType) { var factory = GetInst(); return factory._Create(instType); }
/// <summary> /// 注册 /// </summary> /// <param name="pType"></param> /// <param name="cType"></param> /// <param name="instType"></param> public void Regist(Type pType, Type cType, InstType instType) { this.Regist(pType, cType, instType, DEFAULTNAME); }
/// <summary> /// 注册 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="qType"></param> /// <param name="instType"></param> /// <param name="name"></param> public void Regist <T>(Type qType, InstType instType, string name) { this.Regist(typeof(T), qType, instType, name); }
private IInstCreator _Create(InstType instType) { return(dic[instType]); }
public static IInstCreator Create(InstType instType) { var factory = GetInst(); return(factory._Create(instType)); }
public InstInfo(InstType type, string opName, int precedence) { Type = type; OpName = opName; Precedence = precedence; }
public Instruction(InstType inst, int value) { Inst = inst; Value = value; }
private static void Add(Instruction inst, InstType flags, string opName = null, int precedence = 0) { _infoTbl[(int)inst] = new InstInfo(flags, opName, precedence); }
/// <summary> /// 注册 /// </summary> /// <typeparam name="T">基类或接口</typeparam> /// <typeparam name="Q">实现类</typeparam> /// <param name="instType">类实例化方式</param> public void Regist <T, Q>(InstType instType) where Q : T { Regist <T, Q>(DEFAULTNAME, instType); }
private IInstCreator _Create(InstType instType) { return dic[instType]; }
/// <summary> /// Sets the <see cref="ArcadeInstruction"/> to be animated. /// </summary> public void SetInstruction(InstType type) { switch (type) { case InstType.START: SetInstruction(startMessage); break; case InstType.DEMONSTRATE: SetInstruction(instructions); break; case InstType.SWING_LEFT: SetInstruction(swingLeft); break; case InstType.SWING_RIGHT: SetInstruction(swingRight); break; case InstType.SWING_FORWARD: SetInstruction(swingForward); break; case InstType.ATTACK: SetInstruction(attack); break; case InstType.ATTACK_LEFT: SetInstruction(attackLeft); break; case InstType.ATTACK_RIGHT: SetInstruction(attackRight); break; case InstType.ATTACK_FORWARD: SetInstruction(attackForward); break; case InstType.GET_READY: SetInstruction(getReady); break; case InstType.LEVEL_1: SetInstruction(level1); break; case InstType.LEVEL_2: SetInstruction(level2); break; case InstType.BOSS_STAGE: SetInstruction(bossStage); break; case InstType.NONE: SetInstruction(blank); break; default: break; } }