private static bool HasAttributeOnMethods(Type objectType, Type attributeType) { Collections.Generic.ISet <MethodInfo> methods = ConfigurationClassParser.GetAllMethodsWithCustomAttributeForClass(objectType, attributeType); foreach (MethodInfo method in methods) { if (Attribute.GetCustomAttribute(method, attributeType) != null) { return(true); } } return(false); }
private void ProcessConfigObjectDefinitions(IObjectDefinitionRegistry registry) { Collections.Generic.ISet <ObjectDefinitionHolder> configCandidates = new HashedSet <ObjectDefinitionHolder>(); foreach (string objectName in registry.GetObjectDefinitionNames()) { IObjectDefinition objectDef = registry.GetObjectDefinition(objectName); if (ConfigurationClassObjectDefinitionReader.CheckConfigurationClassCandidate(objectDef)) { configCandidates.Add(new ObjectDefinitionHolder(objectDef, objectName)); } } //if nothing to process, bail out if (configCandidates.Count == 0) { return; } ConfigurationClassParser parser = new ConfigurationClassParser(_problemReporter); foreach (ObjectDefinitionHolder holder in configCandidates) { IObjectDefinition bd = holder.ObjectDefinition; try { if (bd is AbstractObjectDefinition && ((AbstractObjectDefinition)bd).HasObjectType) { parser.Parse(((AbstractObjectDefinition)bd).ObjectType, holder.ObjectName); } else { //parser.Parse(bd.ObjectTypeName, holder.ObjectName); } } catch (ObjectDefinitionParsingException ex) { throw new ObjectDefinitionStoreException("Failed to load object class: " + bd.ObjectTypeName, ex); } } parser.Validate(); // Read the model and create Object definitions based on its content ConfigurationClassObjectDefinitionReader reader = new ConfigurationClassObjectDefinitionReader(registry, _problemReporter); reader.LoadObjectDefinitions(parser.ConfigurationClasses); }
public void SetUp() { _parser = new ConfigurationClassParser(new FailFastProblemReporter()); }