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; } }
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; } } }
protected ProxyAction(ModuleManager manager, Type classType, Type attributeType) { _Manager = manager; _ClassType = classType ?? throw new ArgumentNullException(); if (attributeType == null) { throw new ArgumentNullException(); } object[] attrs; // Guid attribute. Do not Type.GUID, make sure Guid is used. attrs = _ClassType.GetCustomAttributes(typeof(GuidAttribute), false); if (attrs.Length == 0) { throw new ModuleException($"Use '{typeof(GuidAttribute).FullName}' attribute for '{_ClassType.Name}'."); } _Id = new Guid(((GuidAttribute)attrs[0]).Value); // Module* attribure attrs = _ClassType.GetCustomAttributes(attributeType, false); if (attrs.Length == 0) { throw new ModuleException($"Use '{attributeType.FullName}' attribute for '{_ClassType.Name}' class."); } Attribute = (ModuleActionAttribute)attrs[0]; Initialize(); if (Attribute.Resources) { _Manager.CachedResources = true; string name = _Manager.GetString(Attribute.Name); if (!string.IsNullOrEmpty(name)) { Attribute.Name = name; } } }