Exemplo n.º 1
0
        public void RegisterCreator <T>() where T : new()
        {
            string name = MessageCmdData.GetCmdName(typeof(T));

            if (name == null)
            {
                System.InvalidOperationException ex = new System.InvalidOperationException("missing CmdNameAttribute");
                throw ex;
            }

            m_creators[name] = new TypedCreator <T>();
        }
Exemplo n.º 2
0
            public void RegisterCreator <T>() where T : new()
            {
                Type   type = typeof(T);
                string name = null;

                //Querying Class Attributes
                foreach (Attribute attr in type.GetCustomAttributes(true))
                {
                    CmdNameAttribute cmdNameAttr = attr as CmdNameAttribute;
                    if (cmdNameAttr != null)
                    {
                        name = cmdNameAttr.CmdName;
                    }
                }

                if (name == null)
                {
                    InvalidOperationException ex = new InvalidOperationException("missing CmdNameAttribute");
                    throw ex;
                }

                m_creators[name] = new TypedCreator <T>();
            }