예제 #1
0
        protected ProxyAction(ModuleManager manager, Type classType, Type attributeType)
        {
            if (classType == null) throw new ArgumentNullException("classType");
            if (attributeType == null) throw new ArgumentNullException("attributeType");

            _Manager = manager;
            _ClassType = classType;

            object[] attrs;

            // Guid attribute; get it this way, not as Type.GUID, to be sure the attribute is applied
            attrs = _ClassType.GetCustomAttributes(typeof(GuidAttribute), false);
            if (attrs.Length == 0)
                throw new ModuleException(string.Format(null, "Apply the Guid attribute to the '{0}' class.", _ClassType.Name));

            _Id = new Guid(((GuidAttribute)attrs[0]).Value);

            // Module* attribure
            attrs = _ClassType.GetCustomAttributes(attributeType, false);
            if (attrs.Length == 0)
                throw new ModuleException(string.Format(null, "Apply the '{0}' attribute to the '{1}' class.", attributeType.Name, _ClassType.Name));

            _Attribute = (ModuleActionAttribute)attrs[0];

            Initialize();

            if (_Attribute.Resources)
            {
                _Manager.CachedResources = true;
                string name = _Manager.GetString(_Attribute.Name);
                if (!string.IsNullOrEmpty(name))
                    _Attribute.Name = name;
            }
        }
예제 #2
0
        protected ProxyAction(ModuleManager manager, Guid id, ModuleActionAttribute attribute)
        {
            _Manager  = manager;
            _Id       = id;
            Attribute = attribute;

            Initialize();
        }
예제 #3
0
        protected ProxyAction(ModuleManager manager, Guid id, ModuleActionAttribute attribute)
        {
            _Manager = manager;
            _Id = id;
            _Attribute = attribute;

            Initialize();
        }
예제 #4
0
        protected ProxyAction(ModuleManager manager, EnumerableReader reader, ModuleActionAttribute attribute)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            _Manager = manager;
            _Attribute = attribute;

            _ClassName = (string)reader.Read();
            _Attribute.Name = (string)reader.Read();
            _Id = (Guid)reader.Read();
        }
예제 #5
0
        protected ProxyAction(ModuleManager manager, EnumerableReader reader, ModuleActionAttribute attribute)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            _Manager  = manager;
            Attribute = attribute;

            _ClassName     = (string)reader.Read();
            Attribute.Name = (string)reader.Read();
            _Id            = (Guid)reader.Read();
        }
예제 #6
0
        protected ProxyAction(ModuleManager manager, Type classType, Type attributeType)
        {
            if (classType == null)
            {
                throw new ArgumentNullException("classType");
            }
            if (attributeType == null)
            {
                throw new ArgumentNullException("attributeType");
            }

            _Manager   = manager;
            _ClassType = classType;

            object[] attrs;

            // Guid attribute; get it this way, not as Type.GUID, to be sure the attribute is applied
            attrs = _ClassType.GetCustomAttributes(typeof(GuidAttribute), false);
            if (attrs.Length == 0)
            {
                throw new ModuleException(string.Format(null, "Apply the Guid attribute to the '{0}' class.", _ClassType.Name));
            }

            _Id = new Guid(((GuidAttribute)attrs[0]).Value);

            // Module* attribure
            attrs = _ClassType.GetCustomAttributes(attributeType, false);
            if (attrs.Length == 0)
            {
                throw new ModuleException(string.Format(null, "Apply the '{0}' attribute to the '{1}' class.", attributeType.Name, _ClassType.Name));
            }

            _Attribute = (ModuleActionAttribute)attrs[0];

            Initialize();

            if (_Attribute.Resources)
            {
                _Manager.CachedResources = true;
                string name = _Manager.GetString(_Attribute.Name);
                if (!string.IsNullOrEmpty(name))
                {
                    _Attribute.Name = name;
                }
            }
        }