コード例 #1
0
        /// <summary>
        /// 初始化驱动
        /// </summary>
        public virtual void InitDriver(IRunDevice runDevice, IReceiveFilter receiveFilter)
        {
            ReceiveFilter = receiveFilter;

            this._Commands.Clear();
            System.Reflection.Assembly asm = runDevice.GetType().Assembly;
            Type[] types = asm.GetTypes();
            foreach (Type t in types)
            {
                if (typeof(IProtocolCommand).IsAssignableFrom(t))
                {
                    if (t.Name != "IProtocolCommand" &&
                        t.Name != "ProtocolCommand" &&
                        !t.IsAbstract)
                    {
                        IProtocolCommand cmd = (IProtocolCommand)t.Assembly.CreateInstance(t.FullName);
                        if (cmd != null)
                        {
                            cmd.Setup(this);
                            _Commands.TryAdd(cmd.Name, cmd);
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 初始化驱动
        /// </summary>
        public virtual void InitDriver(IRunDevice runDevice)
        {
            this._Commands.Clear();
            Assembly asm = runDevice.GetType().Assembly;

            Type[] types = asm.GetTypes();
            foreach (Type t in types)
            {
                if (typeof(IProtocolCommand).IsAssignableFrom(t))
                {
                    if (t.Name != "IProtocolCommand" && t.Name != "ProtocolCommand")
                    {
                        IProtocolCommand cmd = (IProtocolCommand)t.Assembly.CreateInstance(t.FullName);
                        if (cmd != null)
                        {
                            cmd.Setup(this);
                            _Commands.TryAdd(cmd.Name, cmd);
                        }
                    }
                }
            }
        }