Exemplo n.º 1
0
 public Instru(string name, string addr, string remark, InstType type)
 {
     this.Name   = name;
     this.Addr   = addr;
     this.Remark = remark;
     this.Type   = type;
 }
Exemplo n.º 2
0
        static Instrument Get(BinaryReaderEx br, InstType it)
        {
            Instrument s = new Instrument();

            s.Read(br, it);

            return(s);
        }
Exemplo n.º 3
0
        public void Read(BinaryReaderEx br, InstType it)
        {
            instType = it;

            switch (it)
            {
            case InstType.Long: ReadLong(br); break;

            case InstType.Short: ReadShort(br); break;
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        /// <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);
                    }
                }
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 8
0
 /// <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);
 }
Exemplo n.º 10
0
 /// <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);
 }
Exemplo n.º 11
0
 /// <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);
 }
Exemplo n.º 12
0
 private IInstCreator _Create(InstType instType)
 {
     return(dic[instType]);
 }
Exemplo n.º 13
0
        public static IInstCreator Create(InstType instType)
        {
            var factory = GetInst();

            return(factory._Create(instType));
        }
Exemplo n.º 14
0
 public InstInfo(InstType type, string opName, int precedence)
 {
     Type       = type;
     OpName     = opName;
     Precedence = precedence;
 }
Exemplo n.º 15
0
 public Instruction(InstType inst, int value)
 {
     Inst  = inst;
     Value = value;
 }
Exemplo n.º 16
0
 private static void Add(Instruction inst, InstType flags, string opName = null, int precedence = 0)
 {
     _infoTbl[(int)inst] = new InstInfo(flags, opName, precedence);
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 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;
        }
    }