private void EnhanceConfigurationClasses(IConfigurableListableObjectFactory objectFactory) { ConfigurationClassEnhancer enhancer = new ConfigurationClassEnhancer(objectFactory); IList <string> objectNames = objectFactory.GetObjectDefinitionNames(); foreach (string name in objectNames) { IObjectDefinition objDef = objectFactory.GetObjectDefinition(name); if (((AbstractObjectDefinition)objDef).HasObjectType) { if (Attribute.GetCustomAttribute(objDef.ObjectType, typeof(ConfigurationAttribute)) != null) { //TODO check type of object isn't infrastructure type. Type configClass = objDef.ObjectType; Type enhancedClass = enhancer.Enhance(configClass); Logger.Debug(m => m("Replacing object definition '{0}' existing class '{1}' with enhanced class", name, configClass.FullName)); ((IConfigurableObjectDefinition)objDef).ObjectType = enhancedClass; } } } }
private void EnhanceConfigurationClasses(IConfigurableListableObjectFactory objectFactory) { ConfigurationClassEnhancer enhancer = new ConfigurationClassEnhancer(objectFactory); IList<string> objectNames = objectFactory.GetObjectDefinitionNames(); foreach (string name in objectNames) { IObjectDefinition objDef = objectFactory.GetObjectDefinition(name); if (((AbstractObjectDefinition)objDef).HasObjectType) { if (Attribute.GetCustomAttribute(objDef.ObjectType, typeof(ConfigurationAttribute)) != null) { //TODO check type of object isn't infrastructure type. Type configClass = objDef.ObjectType; Type enhancedClass = enhancer.Enhance(configClass); Logger.Debug(m => m("Replacing object definition '{0}' existing class '{1}' with enhanced class", name, configClass.FullName)); ((IConfigurableObjectDefinition)objDef).ObjectType = enhancedClass; } } } }