diff --git a/Spring.Net.2010.sln b/Spring.Net.2010.sln index b1bea551..eb88a143 100644 --- a/Spring.Net.2010.sln +++ b/Spring.Net.2010.sln @@ -74,6 +74,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.Mvc.2010", "src\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.Mvc.Tests.2010", "test\Spring\Spring.Web.Mvc.Tests\Spring.Web.Mvc.Tests.2010.csproj", "{D4032434-D9A8-437B-95E8-9D4DE0AD9932}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Configuration.2010", "src\Spring\Spring.Core.Configuration\Spring.Core.Configuration.2010.csproj", "{7B65D538-E863-4F57-8DDC-2C38E4150045}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Configuration.Tests.2010", "test\Spring\Spring.Core.Configuration.Tests\Spring.Core.Configuration.Tests.2010.csproj", "{4F1A206C-09A8-43FF-B791-FE956E99A120}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -434,6 +438,26 @@ Global {D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Any CPU.Build.0 = Release|Any CPU {D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Debug|.NET.ActiveCfg = Debug|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Release|.NET.ActiveCfg = Release|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Release|Any CPU.Build.0 = Release|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7B65D538-E863-4F57-8DDC-2C38E4150045}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Debug|.NET.ActiveCfg = Debug|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Release|.NET.ActiveCfg = Release|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Release|Any CPU.Build.0 = Release|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4F1A206C-09A8-43FF-B791-FE956E99A120}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationAttribute.cs similarity index 89% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationAttribute.cs index 9b00778a..8bfdb6a4 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationAttribute.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// Indicates that a class declares one or more methods and may be processed @@ -27,6 +27,15 @@ namespace Spring.Context.Annotation [AttributeUsage(AttributeTargets.Class)] public class ConfigurationAttribute : Attribute { + + /// + /// Initializes a new instance of the ConfigurationAttribute class. + /// + public ConfigurationAttribute() + { + + } + private string _name; /// diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClass.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClass.cs similarity index 96% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationClass.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClass.cs index 53a594e7..8c22c382 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClass.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClass.cs @@ -5,7 +5,7 @@ using Spring.Core.IO; using Spring.Collections.Generic; using Spring.Objects.Factory.Parsing; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { public class ConfigurationClass { diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassMethod.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassMethod.cs similarity index 95% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationClassMethod.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassMethod.cs index 91fbe3fd..14a7aa78 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassMethod.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassMethod.cs @@ -25,7 +25,7 @@ using Spring.Core.IO; using System.Reflection; using Spring.Objects.Factory.Parsing; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /** diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassObjectDefinitionReader.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs similarity index 93% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationClassObjectDefinitionReader.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs index b6c47476..e50b5a3e 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassObjectDefinitionReader.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassObjectDefinitionReader.cs @@ -8,7 +8,7 @@ using System.Reflection; using Spring.Objects.Factory.Config; using Common.Logging; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { public class ConfigurationClassObjectDefinitionReader { @@ -33,7 +33,7 @@ namespace Spring.Context.Annotation { if (type != null) { - return (Attribute.GetCustomAttribute(type.GetType(), typeof(ConfigurationAttribute)) != null); + return (Attribute.GetCustomAttribute(type, typeof(ConfigurationAttribute)) != null); } return false; @@ -58,14 +58,14 @@ namespace Spring.Context.Annotation // no bean definition exists yet -> this must be an imported configuration class (@Import). GenericObjectDefinition configBeanDef = new GenericObjectDefinition(); String className = configClass.ConfigurationClassType.Name; - configBeanDef.ObjectTypeName = className; + configBeanDef.ObjectType = configClass.GetType(); if (CheckConfigurationClassCandidate(configClass.ConfigurationClassType)) { String configObjectName = ObjectDefinitionReaderUtils.RegisterWithGeneratedName(configBeanDef, _registry); configClass.ObjectName = configObjectName; if (_logger.IsDebugEnabled) { - _logger.Debug(String.Format("Registered bean definition for imported [Configuration] class {0}", configObjectName)); + _logger.Debug(String.Format("Registered object definition for imported [Configuration] class {0}", configObjectName)); } } } @@ -102,6 +102,10 @@ namespace Spring.Context.Annotation for (int i = 0; i < objectAttributes.Length; i++) { string[] namesAndAliases = ((DefinitionAttribute)objectAttributes[i]).Name; + + if (namesAndAliases == null) + namesAndAliases = new[] { metadata.Name }; + for (int j = 0; j > namesAndAliases.Length; j++) { names.Add(namesAndAliases[j]); diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassParser.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassParser.cs similarity index 96% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationClassParser.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassParser.cs index 1a681a5a..04c907f4 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassParser.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassParser.cs @@ -6,7 +6,7 @@ using Spring.Collections.Generic; using Spring.Util; using System.Reflection; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { public class ConfigurationClassParser diff --git a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassPostProcessor.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassPostProcessor.cs similarity index 56% rename from src/Spring/Spring.Core/Context/Annotation/ConfigurationClassPostProcessor.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassPostProcessor.cs index 17a46adc..f21fb73d 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ConfigurationClassPostProcessor.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ConfigurationClassPostProcessor.cs @@ -7,10 +7,11 @@ using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Config; using Spring.Collections.Generic; using Spring.Objects.Factory; +using Spring.Core; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { - public class ConfigurationClassPostProcessor : IObjectDefinitionRegistryPostProcessor + public class ConfigurationClassPostProcessor : IObjectDefinitionRegistryPostProcessor, IOrdered { private ILog _logger = LogManager.GetLogger(typeof(ConfigurationClassPostProcessor)); @@ -25,10 +26,7 @@ namespace Spring.Context.Annotation set { _problemReporter = (value ?? new FailFastProblemReporter()); } } - //public int getOrder() - //{ - // return Ordered.HIGHEST_PRECEDENCE; - //} + public void PostProcessObjectDefinitionRegistry(IObjectDefinitionRegistry registry) { @@ -44,24 +42,64 @@ namespace Spring.Context.Annotation ProcessConfigObjectDefinitions(registry); } - /* - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) + + private Type GenerateProxyType(Type objectType) + { + /* + ProxyFactory proxyFactory = new ProxyFactory(); + proxyFactory.ProxyTargetAttributes = true; + proxyFactory.Interfaces = Type.EmptyTypes; + proxyFactory.TargetSource = new ObjectFactoryTargetSource(originalBeanName, owningObjectFactory); + SpringObjectMethodInterceptor methodInterceptor = new SpringObjectMethodInterceptor(owningObjectFactory, objectNamingStrategy); + proxyFactory.AddAdvice(methodInterceptor); + + //TODO check type of object isn't infrastructure type. + + InheritanceAopProxyTypeBuilder iaptb = new InheritanceAopProxyTypeBuilder(proxyFactory); + //iaptb.ProxyDeclaredMembersOnly = true; // make configurable. + Type type = iaptb.BuildProxyType(); + */ + + return null; + } + private void EnhanceConfigurationClasses(IConfigurableListableObjectFactory objectFactory) + { + string[] objectNames = objectFactory.GetObjectDefinitionNames(); + + for (int i = 0; i < objectNames.Length; i++) + { + IObjectDefinition objDef = objectFactory.GetObjectDefinition(objectNames[i]); + if (Attribute.GetCustomAttribute(objDef.ObjectType, typeof(ConfigurationAttribute)) != null) { - if (this.postProcessBeanFactoryCalled) - { - throw new IllegalStateException( - "postProcessBeanFactory already called for this post-processor"); - } - this.postProcessBeanFactoryCalled = true; - if (!this.postProcessBeanDefinitionRegistryCalled) - { - // BeanDefinitionRegistryPostProcessor hook apparently not supported... - // Simply call processConfigBeanDefinitions lazily at this point then. - processConfigBeanDefinitions((BeanDefinitionRegistry)beanFactory); - } - enhanceConfigurationClasses(beanFactory); + //configNames.Add(objectNames[i]); + + //ObjectType is READONLY :( + //objDef.ObjectType = GenerateProxyType(objDef.ObjectType); } - */ + } + + + + + } + public void PostProcessObjectFactory(IConfigurableListableObjectFactory objectFactory) + { + if (_postProcessObjectFactoryCalled) + { + throw new InvalidOperationException( + "PostProcessObjectFactory already called for this post-processor"); + } + _postProcessObjectFactoryCalled = true; + if (!_postProcessObjectDefinitionRegistryCalled) + { + // BeanDefinitionRegistryPostProcessor hook apparently not supported... + // Simply call processConfigBeanDefinitions lazily at this point then. + ProcessConfigObjectDefinitions((IObjectDefinitionRegistry)objectFactory); + } + + EnhanceConfigurationClasses(objectFactory); + } + private void ProcessConfigObjectDefinitions(IObjectDefinitionRegistry registry) { @@ -105,5 +143,10 @@ namespace Spring.Context.Annotation reader.LoadObjectDefinitions(parser.ConfigurationClasses); } + + public int Order + { + get { return int.MinValue; } + } } } diff --git a/src/Spring/Spring.Core/Context/Annotation/DefinitionAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/DefinitionAttribute.cs similarity index 95% rename from src/Spring/Spring.Core/Context/Annotation/DefinitionAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/DefinitionAttribute.cs index 8f00d403..39efce04 100644 --- a/src/Spring/Spring.Core/Context/Annotation/DefinitionAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/DefinitionAttribute.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using Spring.Objects.Factory.Config; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { [AttributeUsage(AttributeTargets.Method)] public class DefinitionAttribute : Attribute diff --git a/src/Spring/Spring.Core/Context/Annotation/DependsOnAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/DependsOnAttribute.cs similarity index 95% rename from src/Spring/Spring.Core/Context/Annotation/DependsOnAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/DependsOnAttribute.cs index 94f46207..ff8c220f 100644 --- a/src/Spring/Spring.Core/Context/Annotation/DependsOnAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/DependsOnAttribute.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// objects on which the current object depends. Any objects specified are guaranteed to be diff --git a/src/Spring/Spring.Core/Context/Annotation/ImportAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ImportAttribute.cs similarity index 95% rename from src/Spring/Spring.Core/Context/Annotation/ImportAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ImportAttribute.cs index 9f01c55d..fa381774 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ImportAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ImportAttribute.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// Indicates one or more classes to import. diff --git a/src/Spring/Spring.Core/Context/Annotation/ImportResourceAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ImportResourceAttribute.cs similarity index 94% rename from src/Spring/Spring.Core/Context/Annotation/ImportResourceAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ImportResourceAttribute.cs index 1b798e32..83fdc689 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ImportResourceAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ImportResourceAttribute.cs @@ -4,7 +4,7 @@ using System.Text; using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// diff --git a/src/Spring/Spring.Core/Context/Annotation/LazyAttrribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/LazyAttrribute.cs similarity index 95% rename from src/Spring/Spring.Core/Context/Annotation/LazyAttrribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/LazyAttrribute.cs index 1eba0cf4..99ba99b1 100644 --- a/src/Spring/Spring.Core/Context/Annotation/LazyAttrribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/LazyAttrribute.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// Indicates whether a object is to be lazily initialized. diff --git a/src/Spring/Spring.Core/Context/Annotation/PrimaryAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/PrimaryAttribute.cs similarity index 93% rename from src/Spring/Spring.Core/Context/Annotation/PrimaryAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/PrimaryAttribute.cs index 5e1b717f..f52187f2 100644 --- a/src/Spring/Spring.Core/Context/Annotation/PrimaryAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/PrimaryAttribute.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// Indicates that an object should be given preference when multiple candidates diff --git a/src/Spring/Spring.Core/Context/Annotation/ScopeAttribute.cs b/src/Spring/Spring.Core.Configuration/Context/Attributes/ScopeAttribute.cs similarity index 94% rename from src/Spring/Spring.Core/Context/Annotation/ScopeAttribute.cs rename to src/Spring/Spring.Core.Configuration/Context/Attributes/ScopeAttribute.cs index 6ac5d81e..7f0370f7 100644 --- a/src/Spring/Spring.Core/Context/Annotation/ScopeAttribute.cs +++ b/src/Spring/Spring.Core.Configuration/Context/Attributes/ScopeAttribute.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using Spring.Objects.Factory.Support; -namespace Spring.Context.Annotation +namespace Spring.Context.Attributes { /// /// When used as a type-level attribute, indicates the name of a scope to use diff --git a/src/Spring/Spring.Core.Configuration/Properties/AssemblyInfo.cs b/src/Spring/Spring.Core.Configuration/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1aee5470 --- /dev/null +++ b/src/Spring/Spring.Core.Configuration/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Spring.Core.Configuration")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Spring.Core.Configuration")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("aa7c95ac-e82f-4c33-a857-76b179c34166")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Spring/Spring.Core.Configuration/Spring.Core.Configuration.2010.csproj b/src/Spring/Spring.Core.Configuration/Spring.Core.Configuration.2010.csproj new file mode 100644 index 00000000..62e04478 --- /dev/null +++ b/src/Spring/Spring.Core.Configuration/Spring.Core.Configuration.2010.csproj @@ -0,0 +1,76 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {7B65D538-E863-4F57-8DDC-2C38E4150045} + Library + Properties + Spring + Spring.Core.Configuration + v2.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\lib\Net\2.0\Common.Logging.dll + + + + + + + + + + + + + + + + + + + + + + + + + {3A3A4E65-45A6-4B20-B460-0BEDC302C02C} + Spring.Aop.2010 + + + {710961A3-0DF4-49E4-A26E-F5B9C044AC84} + Spring.Core.2010 + + + + + \ No newline at end of file diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs index f4898c0a..292d4fc2 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistryPostProcessor.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using System.Text; +using Spring.Objects.Factory.Config; namespace Spring.Objects.Factory.Support { - public interface IObjectDefinitionRegistryPostProcessor + public interface IObjectDefinitionRegistryPostProcessor : IObjectFactoryPostProcessor { void PostProcessObjectDefinitionRegistry(IObjectDefinitionRegistry registry); } diff --git a/src/Spring/Spring.Core/Spring.Core.2010.csproj b/src/Spring/Spring.Core/Spring.Core.2010.csproj index 1aab03b2..82436338 100644 --- a/src/Spring/Spring.Core/Spring.Core.2010.csproj +++ b/src/Spring/Spring.Core/Spring.Core.2010.csproj @@ -171,19 +171,6 @@ Code - - - - - - - - - - - - - Code @@ -1274,6 +1261,7 @@ true + rem $(ProjectDir)..\..\..\build-support\tools\antlr-2.7.6\antlr-2.7.6.exe -o $(ProjectDir)Expressions\Parser $(ProjectDir)Expressions\Expression.g diff --git a/test/Spring/Spring.Core.Configuration.Tests/Context/Attributes/ConfigurationClassPostProcessorTests.cs b/test/Spring/Spring.Core.Configuration.Tests/Context/Attributes/ConfigurationClassPostProcessorTests.cs new file mode 100644 index 00000000..50351b9b --- /dev/null +++ b/test/Spring/Spring.Core.Configuration.Tests/Context/Attributes/ConfigurationClassPostProcessorTests.cs @@ -0,0 +1,84 @@ +using System; +using NUnit.Framework; +using Spring.Context.Support; +using Spring.Objects.Factory.Support; +using Spring.Context.Attributes; + +namespace Spring.Context.Annotation +{ + [TestFixture] + public class ConfigurationClassPostProcessorTests + { + private GenericApplicationContext _ctx; + + private ConfigurationClassPostProcessor _postProcessor; + + [SetUp] + public void _SetUp() + { + _ctx = new GenericApplicationContext(); + + var builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(ObjectDefinitions)); + _ctx.RegisterObjectDefinition("whoCares", builder.ObjectDefinition); + + _postProcessor = new ConfigurationClassPostProcessor(); + _postProcessor.PostProcessObjectDefinitionRegistry(_ctx); + } + + [Test] + public void CanRegisterDefintions() + { + Assert.That(_ctx.ObjectDefinitionCount, Is.EqualTo(3)); + } + + [Test] + public void CanRetreiveActualObjectsFromContext() + { + Assert.That(_ctx[typeof(Parent).Name], Is.TypeOf()); + Assert.That(_ctx[typeof(Child).Name], Is.TypeOf()); + } + + [Test] + public void CanSatisfyDependenciesOfObjects() + { + Assert.That(((Parent)_ctx[typeof(Parent).Name]).Child, Is.Not.Null); + } + + } + + [Configuration] + public class ObjectDefinitions + { + [Definition] + public Parent Parent() + { + return new Parent(Child()); + } + + [Definition] + public Child Child() + { + return new Child(); + } + } + + public class Parent + { + private Child _child; + + public Parent(Child child) + { + _child = child; + } + + public Child Child + { + get + { + return _child; + } + } + + } + public class Child { } +} diff --git a/test/Spring/Spring.Core.Configuration.Tests/Properties/AssemblyInfo.cs b/test/Spring/Spring.Core.Configuration.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a1c1539d --- /dev/null +++ b/test/Spring/Spring.Core.Configuration.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Spring.Core.Configuration.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Spring.Core.Configuration.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("65e12092-0586-435f-b9ef-e4a35c302bef")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/Spring/Spring.Core.Configuration.Tests/Spring.Core.Configuration.Tests.2010.csproj b/test/Spring/Spring.Core.Configuration.Tests/Spring.Core.Configuration.Tests.2010.csproj new file mode 100644 index 00000000..f8a5b557 --- /dev/null +++ b/test/Spring/Spring.Core.Configuration.Tests/Spring.Core.Configuration.Tests.2010.csproj @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {4F1A206C-09A8-43FF-B791-FE956E99A120} + Library + Properties + Spring.Core.Configuration.Tests + Spring.Core.Configuration.Tests + v2.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\lib\Net\2.0\nunit.framework.dll + + + + + + + + + + + + {3A3A4E65-45A6-4B20-B460-0BEDC302C02C} + Spring.Aop.2010 + + + {7B65D538-E863-4F57-8DDC-2C38E4150045} + Spring.Core.Configuration.2010 + + + {710961A3-0DF4-49E4-A26E-F5B9C044AC84} + Spring.Core.2010 + + + + + \ No newline at end of file