From: <jer...@us...> - 2008-01-15 15:15:52
|
Revision: 56 http://structuremap.svn.sourceforge.net/structuremap/?rev=56&view=rev Author: jeremydmiller Date: 2008-01-15 07:15:50 -0800 (Tue, 15 Jan 2008) Log Message: ----------- added quite a bit of stuff to the fluent interface for interception, scanning assemblies, a shortcut to add a type as something other than the default, add an assembly by name Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Graph/AssemblyGraph.cs trunk/Source/StructureMap/Graph/Plugin.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Graph/PluginGraph.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/StructureMapConfiguration.cs trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/ScanAssembliesTester.cs trunk/Source/StructureMap.Testing/Graph/AssemblyGraphTester.cs trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs trunk/Source/StructureMap.Testing/Graph/PluginTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/Delegates.cs trunk/Source/StructureMap.Testing/Configuration/DSL/AddTypesTester.cs trunk/Source/StructureMap.Testing/Container/TypeFindingTester.cs Removed Paths: ------------- trunk/Source/StructureMap/Configuration/DSL/ChildArrayExpression.cs trunk/Source/StructureMap/Configuration/DSL/ChildInstanceExpression.cs trunk/Source/StructureMap/Configuration/DSL/ConstructorExpression.cs trunk/Source/StructureMap/Configuration/DSL/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/LiteralMemento.cs trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs trunk/Source/StructureMap/Configuration/DSL/InstanceExpression.cs trunk/Source/StructureMap/Configuration/DSL/LiteralExpression.cs trunk/Source/StructureMap/Configuration/DSL/LiteralMemento.cs trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs trunk/Source/StructureMap/Configuration/DSL/PropertyExpression.cs trunk/Source/StructureMap/Configuration/DSL/PrototypeExpression.cs trunk/Source/StructureMap/Configuration/DSL/PrototypeMemento.cs trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs trunk/Source/StructureMap/Configuration/DSL/UserControlExpression.cs trunk/Source/StructureMap/Configuration/UserControlMemento.cs Deleted: trunk/Source/StructureMap/Configuration/DSL/ChildArrayExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ChildArrayExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/ChildArrayExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,50 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - public class ChildArrayExpression<PLUGINTYPE> : IExpression - { - private readonly InstanceExpression _parent; - private readonly MemoryInstanceMemento _memento; - private readonly string _propertyName; - private IMementoBuilder[] _builders; - private Type _pluginType = typeof (PLUGINTYPE); - - public ChildArrayExpression(InstanceExpression parent, MemoryInstanceMemento memento, string propertyName) - { - _parent = parent; - _memento = memento; - _propertyName = propertyName; - - _pluginType = typeof (PLUGINTYPE).GetElementType(); - } - - void IExpression.Configure(PluginGraph graph) - { - PluginFamily family = graph.LocateOrCreateFamilyForType(_pluginType); - InstanceMemento[] childMementos = new InstanceMemento[_builders.Length]; - for (int i = 0; i < _builders.Length; i++) - { - InstanceMemento memento = processMementoBuilder(_builders[i], family, graph); - childMementos[i] = memento; - } - - _memento.AddChildArray(_propertyName, childMementos); - } - - private InstanceMemento processMementoBuilder(IMementoBuilder builder, PluginFamily family, PluginGraph graph) - { - builder.ValidatePluggability(_pluginType); - builder.Configure(graph); - return builder.BuildMemento(family); - } - - public InstanceExpression Contains(params IMementoBuilder[] builders) - { - _builders = builders; - - return _parent; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/ChildInstanceExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ChildInstanceExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/ChildInstanceExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Part of the Fluent Interface, represents a nonprimitive argument to a - /// constructure function - /// </summary> - public class ChildInstanceExpression : IExpression - { - private readonly InstanceExpression _instance; - private readonly MemoryInstanceMemento _memento; - private readonly string _propertyName; - private Type _childType; - private List<IExpression> _children = new List<IExpression>(); - private IMementoBuilder _builder; - - - public ChildInstanceExpression(InstanceExpression instance, MemoryInstanceMemento memento, string propertyName) - { - _instance = instance; - _memento = memento; - _propertyName = propertyName; - } - - public ChildInstanceExpression(InstanceExpression instance, MemoryInstanceMemento memento, string propertyName, - Type childType) - : this(instance, memento, propertyName) - { - _childType = childType; - } - - /// <summary> - /// Use a previously configured and named instance for the child - /// </summary> - /// <param name="instanceKey"></param> - /// <returns></returns> - public InstanceExpression IsNamedInstance(string instanceKey) - { - MemoryInstanceMemento child = MemoryInstanceMemento.CreateReferencedInstanceMemento(instanceKey); - _memento.AddChild(_propertyName, child); - - return _instance; - } - - /// <summary> - /// Start the definition of a child instance by defining the concrete type - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - public InstanceExpression IsConcreteType<T>() - { - Type pluggedType = typeof (T); - ExpressionValidator.ValidatePluggabilityOf(pluggedType).IntoPluginType(_childType); - - - InstanceExpression child = new InstanceExpression(_childType); - child.TypeExpression().UsingConcreteType<T>(); - _children.Add(child); - - _builder = child; - - return _instance; - } - - - void IExpression.Configure(PluginGraph graph) - { - if (_childType == null) - { - return; - } - - PluginFamily family = graph.LocateOrCreateFamilyForType(_childType); - if (_builder != null) - { - InstanceMemento childMemento = _builder.BuildMemento(family); - _memento.AddChild(_propertyName, childMemento); - } - - foreach (IExpression child in _children) - { - child.Configure(graph); - } - } - - internal Type ChildType - { - set { _childType = value; } - } - - /// <summary> - /// Registers a configured instance to use as the argument to the parent's - /// constructor - /// </summary> - /// <param name="child"></param> - /// <returns></returns> - public InstanceExpression Is(InstanceExpression child) - { - if (child.PluggedType != null && _childType != null) - { - ExpressionValidator.ValidatePluggabilityOf(child.PluggedType).IntoPluginType(_childType); - } - - _children.Add(child); - MemoryInstanceMemento childMemento = - MemoryInstanceMemento.CreateReferencedInstanceMemento(child.InstanceKey); - _memento.AddChild(_propertyName, childMemento); - - return _instance; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/ConstructorExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ConstructorExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/ConstructorExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,49 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - public class ConstructorExpression<PLUGINTYPE> : MementoBuilder<ConstructorExpression<PLUGINTYPE>> - { - private ConstructorMemento<PLUGINTYPE> _memento; - - public ConstructorExpression(BuildObjectDelegate<PLUGINTYPE> builder) - : base(typeof (PLUGINTYPE)) - { - _memento.Builder = builder; - } - - - protected override InstanceMemento memento - { - get { return _memento; } - } - - protected override ConstructorExpression<PLUGINTYPE> thisInstance - { - get { return this; } - } - - protected override void configureMemento(PluginFamily family) - { - } - - protected override void validate() - { - } - - protected override void buildMemento() - { - _memento = new ConstructorMemento<PLUGINTYPE>(); - } - - public override void ValidatePluggability(Type pluginType) - { - if (!pluginType.Equals(typeof (PLUGINTYPE))) - { - throw new StructureMapException(306, - typeof (PLUGINTYPE).FullName, pluginType.FullName); - } - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/CreatePluginFamilyExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/CreatePluginFamilyExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using StructureMap.Attributes; -using StructureMap.Graph; -using StructureMap.Interceptors; - -namespace StructureMap.Configuration.DSL -{ - public delegate void AlterPluginFamilyDelegate(PluginFamily family); - - /// <summary> - /// Represents the parameters for creating instances of a given Type - /// </summary> - public class CreatePluginFamilyExpression<PLUGINTYPE> : IExpression - { - private Type _pluginType; - private List<AlterPluginFamilyDelegate> _alterations = new List<AlterPluginFamilyDelegate>(); - private InstanceScope _scope = InstanceScope.PerRequest; - private List<IExpression> _children = new List<IExpression>(); - - public CreatePluginFamilyExpression() - { - _pluginType = typeof (PLUGINTYPE); - } - - void IExpression.Configure(PluginGraph graph) - { - PluginFamily family = graph.LocateOrCreateFamilyForType(_pluginType); - InterceptorChainBuilder builder = new InterceptorChainBuilder(); - family.InterceptionChain = builder.Build(_scope); - - foreach (IExpression child in _children) - { - child.Configure(graph); - } - - foreach (AlterPluginFamilyDelegate alteration in _alterations) - { - alteration(family); - } - - graph.PluginFamilies.Add(family); - - AssemblyGraph assembly = new AssemblyGraph(_pluginType.Assembly); - graph.Assemblies.Add(assembly); - } - - /// <summary> - /// Sets the default instance of a Type to the definition represented by builder - /// </summary> - /// <param name="builder"></param> - /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIs(IMementoBuilder builder) - { - builder.ValidatePluggability(_pluginType); - - _children.Add(builder); - _alterations.Add(delegate(PluginFamily family) - { - InstanceMemento memento = builder.BuildMemento(family); - family.Source.AddExternalMemento(memento); - family.DefaultInstanceKey = memento.InstanceKey; - }); - - return this; - } - - public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(IMementoBuilder builder) - { - builder.ValidatePluggability(_pluginType); - - _children.Add(builder); - _alterations.Add(delegate(PluginFamily family) - { - InstanceMemento memento = builder.BuildMemento(family); - family.Source.AddExternalMemento(memento); - }); - - return this; - } - - /// <summary> - /// Convenience method that sets the default concrete type of the PluginType. Type T - /// can only accept types that do not have any primitive constructor arguments. - /// StructureMap has to know how to construct all of the constructor argument types. - /// </summary> - /// <typeparam name="CONCRETETYPE"></typeparam> - /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIsConcreteType<CONCRETETYPE>() - where CONCRETETYPE : PLUGINTYPE - { - ExpressionValidator.ValidatePluggabilityOf(typeof (CONCRETETYPE)).IntoPluginType(_pluginType); - - _alterations.Add(delegate(PluginFamily family) - { - Plugin plugin = family.Plugins.FindOrCreate(typeof (CONCRETETYPE)); - family.DefaultInstanceKey = plugin.ConcreteKey; - }); - - return this; - } - - /// <summary> - /// Sets the object creation of the instances of the PluginType. For example: PerRequest, - /// Singleton, ThreadLocal, HttpContext, or Hybrid - /// </summary> - /// <param name="scope"></param> - /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> CacheBy(InstanceScope scope) - { - _alterations.Add(delegate(PluginFamily family) - { - InterceptorChainBuilder builder = new InterceptorChainBuilder(); - family.InterceptionChain = builder.Build(scope); - }); - - return this; - } - - /// <summary> - /// Convenience method to mark a PluginFamily as a Singleton - /// </summary> - /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> AsSingletons() - { - _alterations.Add( - delegate(PluginFamily family) { family.InterceptionChain.AddInterceptor(new SingletonInterceptor()); }); - return this; - } - - - public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(StartupHandler<PLUGINTYPE> handler) - { - _alterations.Add( - delegate(PluginFamily family) { family.InstanceInterceptor = new StartupInterceptor<PLUGINTYPE>(handler); }); - - return this; - } - - public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(EnrichmentHandler<PLUGINTYPE> handler) - { - _alterations.Add( - delegate(PluginFamily family) { family.InstanceInterceptor = new EnrichmentInterceptor<PLUGINTYPE>(handler); }); - - return this; - } - } -} \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using StructureMap.Attributes; +using StructureMap.Configuration.Mementos; using StructureMap.Graph; using StructureMap.Interceptors; @@ -13,16 +14,18 @@ /// </summary> public class CreatePluginFamilyExpression<PLUGINTYPE> : IExpression { + private readonly List<AlterPluginFamilyDelegate> _alterations = new List<AlterPluginFamilyDelegate>(); + private readonly List<IExpression> _children = new List<IExpression>(); private readonly Type _pluginType; - private readonly List<AlterPluginFamilyDelegate> _alterations = new List<AlterPluginFamilyDelegate>(); private readonly InstanceScope _scope = InstanceScope.PerRequest; - private readonly List<IExpression> _children = new List<IExpression>(); public CreatePluginFamilyExpression() { _pluginType = typeof (PLUGINTYPE); } + #region IExpression Members + void IExpression.Configure(PluginGraph graph) { PluginFamily family = graph.LocateOrCreateFamilyForType(_pluginType); @@ -45,6 +48,8 @@ graph.Assemblies.Add(assembly); } + #endregion + /// <summary> /// Sets the default instance of a Type to the definition represented by builder /// </summary> @@ -144,5 +149,30 @@ return this; } + + public CreatePluginFamilyExpression<PLUGINTYPE> AddConcreteType<CONCRETETYPE>() + { + return AddConcreteType<CONCRETETYPE>(Guid.NewGuid().ToString()); + } + + public CreatePluginFamilyExpression<PLUGINTYPE> AddConcreteType<CONCRETETYPE>(string instanceName) + { + _alterations.Add( + delegate(PluginFamily family) + { + Plugin plugin = Plugin.CreateImplicitPlugin(typeof (CONCRETETYPE)); + plugin.ConcreteKey = instanceName; + family.Plugins.Add(plugin); + } + ); + + return this; + } + + public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(InstanceFactoryInterceptor interceptor) + { + _alterations.Add(delegate(PluginFamily family){family.InterceptionChain.AddInterceptor(interceptor);}); + return this; + } } } \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/Expressions/LiteralMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/LiteralMemento.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/LiteralMemento.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,67 +0,0 @@ -using System; - -namespace StructureMap.Configuration.DSL.Expressions -{ - public class LiteralMemento : InstanceMemento - { - private object _instance; - - public LiteralMemento(object instance) - { - _instance = instance; - InstanceKey = Guid.NewGuid().ToString(); - } - - public LiteralMemento Named(string name) - { - InstanceKey = name; - return this; - } - - public object Instance - { - get { return _instance; } - set { _instance = value; } - } - - protected override string innerConcreteKey - { - get { throw new NotImplementedException(); } - } - - protected override string innerInstanceKey - { - get { throw new NotImplementedException(); } - } - - protected override string getPropertyValue(string Key) - { - throw new NotImplementedException(); - } - - protected override InstanceMemento getChild(string Key) - { - throw new NotImplementedException(); - } - - public override InstanceMemento[] GetChildrenArray(string Key) - { - throw new NotImplementedException(); - } - - public override bool IsReference - { - get { return false; } - } - - public override string ReferenceKey - { - get { throw new NotImplementedException(); } - } - - protected override object buildInstance(IInstanceCreator creator) - { - return _instance; - } - } -} \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -10,7 +10,7 @@ public class ProfileExpression : IExpression { private readonly string _profileName; - private List<InstanceDefaultExpression> _defaults = new List<InstanceDefaultExpression>(); + private readonly List<InstanceDefaultExpression> _defaults = new List<InstanceDefaultExpression>(); public ProfileExpression(string profileName) { Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -12,8 +12,14 @@ /// </summary> public class ScanAssembliesExpression : IExpression { - private List<AssemblyGraph> _assemblies = new List<AssemblyGraph>(); + private readonly Registry _registry; + private readonly List<AssemblyGraph> _assemblies = new List<AssemblyGraph>(); + public ScanAssembliesExpression(Registry registry) + { + _registry = registry; + } + void IExpression.Configure(PluginGraph graph) { foreach (AssemblyGraph assembly in _assemblies) @@ -59,5 +65,23 @@ return this; } + + public ScanAssembliesExpression AddAllTypesOf<PLUGINTYPE>() + { + _registry.addExpression(delegate (PluginGraph pluginGraph) + { + PluginFamily family = + pluginGraph.LocateOrCreateFamilyForType(typeof (PLUGINTYPE)); + family.CanUseUnMarkedPlugins = true; + }); + + return this; + } + + public ScanAssembliesExpression IncludeAssembly(string assemblyName) + { + _assemblies.Add(new AssemblyGraph(assemblyName)); + return this; + } } } \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,14 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - public interface IMementoBuilder : IExpression - { - InstanceMemento BuildMemento(PluginFamily family); - InstanceMemento BuildMemento(PluginGraph graph); - void SetInstanceName(string instanceKey); - - void ValidatePluggability(Type pluginType); - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,69 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Use to express the instance of a PluginType for the containing Profile - /// </summary> - public class InstanceDefaultExpression - { - private readonly Type _pluginType; - private readonly ProfileExpression _parent; - private string _instanceKey = string.Empty; - private IMementoBuilder _mementoBuilder; - - public InstanceDefaultExpression(Type pluginType, ProfileExpression parent) - { - _pluginType = pluginType; - _parent = parent; - } - - /// <summary> - /// Use a named, preconfigured instance as the default instance for this profile - /// </summary> - /// <param name="instanceKey"></param> - /// <returns></returns> - public ProfileExpression UseNamedInstance(string instanceKey) - { - _instanceKey = instanceKey; - return _parent; - } - - internal void Configure(Profile profile, PluginGraph graph) - { - if (!string.IsNullOrEmpty(_instanceKey)) - { - InstanceDefault instanceDefault = new InstanceDefault(_pluginType, _instanceKey); - profile.AddOverride(instanceDefault); - } - else if (_mementoBuilder != null) - { - string defaultKey = Profile.InstanceKeyForProfile(profile.ProfileName); - InstanceMemento memento = _mementoBuilder.BuildMemento(graph); - memento.InstanceKey = defaultKey; - - graph.PluginFamilies[_pluginType].AddInstance(memento); - - InstanceDefault instanceDefault = new InstanceDefault(_pluginType, defaultKey); - profile.AddOverride(instanceDefault); - } - else - { - throw new StructureMapException(304, TypePath.GetAssemblyQualifiedName(_pluginType)); - } - } - - /// <summary> - /// Define the default instance of the PluginType for the containing Profile - /// </summary> - /// <param name="mementoBuilder"></param> - /// <returns></returns> - public ProfileExpression Use(IMementoBuilder mementoBuilder) - { - _mementoBuilder = mementoBuilder; - - return _parent; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/InstanceExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/InstanceExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/InstanceExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,192 +0,0 @@ -using System; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Used to define an Instance in code - /// </summary> - public class InstanceExpression : MementoBuilder<InstanceExpression> - { - private Type _pluggedType; - private MemoryInstanceMemento _memento; - - public InstanceExpression(Type pluginType) : base(pluginType) - { - } - - - internal Type PluggedType - { - get { return _pluggedType; } - } - - protected override void buildMemento() - { - _memento = new MemoryInstanceMemento(); - } - - - protected override InstanceMemento memento - { - get { return _memento; } - } - - protected override InstanceExpression thisInstance - { - get { return this; } - } - - protected override void configureMemento(PluginFamily family) - { - Plugin plugin = _pluggedType == null - ? family.Plugins[_memento.ConcreteKey] - : family.Plugins.FindOrCreate(_pluggedType); - - _memento.ConcreteKey = plugin.ConcreteKey; - } - - protected override void validate() - { - if (_pluggedType == null && string.IsNullOrEmpty(_memento.ConcreteKey)) - { - throw new StructureMapException(301, _memento.InstanceKey, - TypePath.GetAssemblyQualifiedName(_pluginType)); - } - } - - - /// <summary> - /// Start the definition of a primitive argument to a constructor argument - /// </summary> - /// <param name="propertyName"></param> - /// <returns></returns> - public PropertyExpression WithProperty(string propertyName) - { - return new PropertyExpression(this, _memento, propertyName); - } - - /// <summary> - /// Starts the definition of a child instance specifying the argument name - /// in the case of a constructor function that consumes more than one argument - /// of type T - /// </summary> - /// <typeparam name="CONSTRUCTORARGUMENTTYPE"></typeparam> - /// <param name="propertyName"></param> - /// <returns></returns> - public ChildInstanceExpression Child<CONSTRUCTORARGUMENTTYPE>(string propertyName) - { - ChildInstanceExpression child = new ChildInstanceExpression(this, _memento, propertyName); - addChildExpression(child); - child.ChildType = typeof (CONSTRUCTORARGUMENTTYPE); - - return child; - } - - /// <summary> - /// Start the definition of a child instance for type CONSTRUCTORARGUMENTTYPE - /// </summary> - /// <typeparam name="CONSTRUCTORARGUMENTTYPE"></typeparam> - /// <returns></returns> - public ChildInstanceExpression Child<CONSTRUCTORARGUMENTTYPE>() - { - string propertyName = findPropertyName<CONSTRUCTORARGUMENTTYPE>(); - - ChildInstanceExpression child = new ChildInstanceExpression(this, _memento, propertyName); - addChildExpression(child); - child.ChildType = typeof (CONSTRUCTORARGUMENTTYPE); - return child; - } - - private string findPropertyName<T>() - { - Plugin plugin = Plugin.CreateImplicitPlugin(_pluggedType); - string propertyName = plugin.FindFirstConstructorArgumentOfType<T>(); - - if (string.IsNullOrEmpty(propertyName)) - { - throw new StructureMapException(305, TypePath.GetAssemblyQualifiedName(typeof (T))); - } - - return propertyName; - } - - public override void ValidatePluggability(Type pluginType) - { - if (_pluggedType == null) - { - return; - } - - ExpressionValidator.ValidatePluggabilityOf(_pluggedType).IntoPluginType(pluginType); - } - - internal InstanceTypeExpression TypeExpression() - { - return new InstanceTypeExpression(this); - } - - /// <summary> - /// Helper class to capture the actual concrete type of an Instance - /// </summary> - public class InstanceTypeExpression - { - private readonly InstanceExpression _parent; - - internal InstanceTypeExpression(InstanceExpression parent) - { - _parent = parent; - } - - /// <summary> - /// Use type T for the concrete type of an instance - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - public InstanceExpression UsingConcreteType<T>() - { - _parent._pluggedType = typeof (T); - return _parent; - } - - /// <summary> - /// Use a named Plugin type denoted by a [Pluggable("Key")] attribute - /// </summary> - /// <param name="concreteKey"></param> - /// <returns></returns> - public InstanceExpression UsingConcreteTypeNamed(string concreteKey) - { - _parent._memento.ConcreteKey = concreteKey; - return _parent; - } - } - - public ChildArrayExpression<PLUGINTYPE> ChildArray<PLUGINTYPE>() - { - validateTypeIsArray<PLUGINTYPE>(); - - string propertyName = findPropertyName<PLUGINTYPE>(); - return ChildArray<PLUGINTYPE>(propertyName); - } - - public ChildArrayExpression<PLUGINTYPE> ChildArray<PLUGINTYPE>(string propertyName) - { - validateTypeIsArray<PLUGINTYPE>(); - - ChildArrayExpression<PLUGINTYPE> expression = - new ChildArrayExpression<PLUGINTYPE>(this, _memento, propertyName); - addChildExpression(expression); - - return expression; - } - - private static void validateTypeIsArray<PLUGINTYPE>() - { - if (!typeof (PLUGINTYPE).IsArray) - { - throw new StructureMapException(307); - } - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/LiteralExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/LiteralExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/LiteralExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,50 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Small helper class to represent an object to be plugged into a PluginType as is - /// </summary> - /// <typeparam name="T"></typeparam> - public class LiteralExpression<T> : MementoBuilder<LiteralExpression<T>> - { - private readonly T _target; - private LiteralMemento _memento; - - public LiteralExpression(T target) : base(typeof (T)) - { - _target = target; - } - - - protected override InstanceMemento memento - { - get { return _memento; } - } - - protected override LiteralExpression<T> thisInstance - { - get { return this; } - } - - protected override void configureMemento(PluginFamily family) - { - _memento.Instance = _target; - } - - protected override void validate() - { - } - - protected override void buildMemento() - { - _memento = new LiteralMemento(null); - } - - public override void ValidatePluggability(Type pluginType) - { - ExpressionValidator.ValidatePluggabilityOf(_target.GetType()).IntoPluginType(pluginType); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/LiteralMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/LiteralMemento.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/LiteralMemento.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,67 +0,0 @@ -using System; - -namespace StructureMap.Configuration.DSL -{ - public class LiteralMemento : InstanceMemento - { - private object _instance; - - public LiteralMemento(object instance) - { - _instance = instance; - InstanceKey = Guid.NewGuid().ToString(); - } - - public LiteralMemento Named(string name) - { - InstanceKey = name; - return this; - } - - public object Instance - { - get { return _instance; } - set { _instance = value; } - } - - protected override string innerConcreteKey - { - get { throw new NotImplementedException(); } - } - - protected override string innerInstanceKey - { - get { throw new NotImplementedException(); } - } - - protected override string getPropertyValue(string Key) - { - throw new NotImplementedException(); - } - - protected override InstanceMemento getChild(string Key) - { - throw new NotImplementedException(); - } - - public override InstanceMemento[] GetChildrenArray(string Key) - { - throw new NotImplementedException(); - } - - public override bool IsReference - { - get { return false; } - } - - public override string ReferenceKey - { - get { throw new NotImplementedException(); } - } - - protected override object buildInstance(IInstanceCreator creator) - { - return _instance; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; -using StructureMap.Interceptors; - -namespace StructureMap.Configuration.DSL -{ - // TODO -- T must be constrained to be MementoBuilder - public abstract class MementoBuilder<T> : IExpression, IMementoBuilder - { - protected readonly Type _pluginType; - protected List<IExpression> _children = new List<IExpression>(); - private string _instanceKey = null; - - public MementoBuilder(Type pluginType) - { - _pluginType = pluginType; - buildMemento(); - memento.InstanceKey = Guid.NewGuid().ToString(); - } - - void IExpression.Configure(PluginGraph graph) - { - validate(); - PluginFamily family = graph.LocateOrCreateFamilyForType((Type) _pluginType); - configureMemento(family); - - if (!string.IsNullOrEmpty(_instanceKey)) - { - memento.InstanceKey = _instanceKey; - } - - family.Source.AddExternalMemento(memento); - - foreach (IExpression child in _children) - { - child.Configure(graph); - } - } - - protected abstract InstanceMemento memento { get; } - - protected abstract T thisInstance { get; } - - protected abstract void configureMemento(PluginFamily family); - - protected abstract void validate(); - - public T WithName(string instanceKey) - { - memento.InstanceKey = instanceKey; - return thisInstance; - } - - public T OnCreation<TYPE>(StartupHandler<TYPE> handler) - { - StartupInterceptor<TYPE> interceptor = new StartupInterceptor<TYPE>(handler); - memento.Interceptor = interceptor; - - return thisInstance; - } - - public T EnrichWith<TYPE>(EnrichmentHandler<TYPE> handler) - { - EnrichmentInterceptor<TYPE> interceptor = new EnrichmentInterceptor<TYPE>(handler); - memento.Interceptor = interceptor; - - return thisInstance; - } - - public string InstanceKey - { - get { return memento.InstanceKey; } - set { memento.InstanceKey = value; } - } - - internal Type PluginType - { - get { return _pluginType; } - } - - protected abstract void buildMemento(); - - InstanceMemento IMementoBuilder.BuildMemento(PluginFamily family) - { - return buildMementoFromFamily(family); - } - - private InstanceMemento buildMementoFromFamily(PluginFamily family) - { - validate(); - configureMemento(family); - return memento; - } - - - InstanceMemento IMementoBuilder.BuildMemento(PluginGraph graph) - { - PluginFamily family = graph.LocateOrCreateFamilyForType(_pluginType); - return buildMementoFromFamily(family); - } - - public void SetInstanceName(string instanceKey) - { - _instanceKey = instanceKey; - } - - public abstract void ValidatePluggability(Type pluginType); - - protected void addChildExpression(IExpression expression) - { - _children.Add(expression); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Expression class to help define a runtime Profile - /// </summary> - public class ProfileExpression : IExpression - { - private readonly string _profileName; - private List<InstanceDefaultExpression> _defaults = new List<InstanceDefaultExpression>(); - - public ProfileExpression(string profileName) - { - _profileName = profileName; - } - - void IExpression.Configure(PluginGraph graph) - { - Profile profile = graph.DefaultManager.GetProfile(_profileName); - if (profile == null) - { - profile = new Profile(_profileName); - graph.DefaultManager.AddProfile(profile); - } - - foreach (InstanceDefaultExpression expression in _defaults) - { - expression.Configure(profile, graph); - } - } - - /// <summary> - /// Starts the definition of the default instance for the containing Profile - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - public InstanceDefaultExpression For<T>() - { - InstanceDefaultExpression defaultExpression = new InstanceDefaultExpression(typeof (T), this); - _defaults.Add(defaultExpression); - - return defaultExpression; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/PropertyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/PropertyExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/PropertyExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,45 +0,0 @@ -using System.Configuration; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Defines the value of a primitive argument to a constructur argument - /// </summary> - public class PropertyExpression - { - private readonly InstanceExpression _instance; - private readonly MemoryInstanceMemento _memento; - private readonly string _propertyName; - - public PropertyExpression(InstanceExpression instance, MemoryInstanceMemento memento, string propertyName) - { - _instance = instance; - _memento = memento; - _propertyName = propertyName; - } - - /// <summary> - /// Sets the value of the constructor argument - /// </summary> - /// <param name="propertyValue"></param> - /// <returns></returns> - public InstanceExpression EqualTo(object propertyValue) - { - _memento.SetProperty(_propertyName, propertyValue.ToString()); - return _instance; - } - - /// <summary> - /// Sets the value of the constructor argument to the key/value in the - /// AppSettings - /// </summary> - /// <param name="appSettingKey"></param> - /// <returns></returns> - public InstanceExpression EqualToAppSetting(string appSettingKey) - { - string propertyValue = ConfigurationManager.AppSettings[appSettingKey]; - _memento.SetProperty(_propertyName, propertyValue); - return _instance; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/PrototypeExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/PrototypeExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/PrototypeExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,50 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Sets up a Prototype instance of type T - /// </summary> - /// <typeparam name="T"></typeparam> - public class PrototypeExpression<T> : MementoBuilder<PrototypeExpression<T>> - { - private readonly T _prototype; - private PrototypeMemento _memento; - - public PrototypeExpression(T prototype) : base(typeof (T)) - { - _prototype = prototype; - } - - protected override InstanceMemento memento - { - get { return _memento; } - } - - protected override PrototypeExpression<T> thisInstance - { - get { return this; } - } - - protected override void configureMemento(PluginFamily family) - { - _memento.Prototype = (ICloneable) _prototype; - } - - protected override void validate() - { - // TODO - } - - protected override void buildMemento() - { - _memento = new PrototypeMemento(string.Empty, (ICloneable) _prototype); - } - - public override void ValidatePluggability(Type pluginType) - { - ExpressionValidator.ValidatePluggabilityOf(_prototype.GetType()).IntoPluginType(pluginType); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/PrototypeMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/PrototypeMemento.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/PrototypeMemento.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,63 +0,0 @@ -using System; - -namespace StructureMap.Configuration.DSL -{ - public class PrototypeMemento : InstanceMemento - { - private readonly string _instanceKey; - private ICloneable _prototype; - - public PrototypeMemento(string instanceKey, ICloneable prototype) - { - _instanceKey = instanceKey; - _prototype = prototype; - } - - - public ICloneable Prototype - { - get { return _prototype; } - set { _prototype = value; } - } - - protected override object buildInstance(IInstanceCreator creator) - { - return _prototype.Clone(); - } - - protected override string innerConcreteKey - { - get { return string.Empty; } - } - - protected override string innerInstanceKey - { - get { return _instanceKey; } - } - - protected override string getPropertyValue(string Key) - { - throw new NotImplementedException(); - } - - protected override InstanceMemento getChild(string Key) - { - throw new NotImplementedException(); - } - - public override InstanceMemento[] GetChildrenArray(string Key) - { - throw new NotImplementedException(); - } - - public override bool IsReference - { - get { return false; } - } - - public override string ReferenceKey - { - get { throw new NotImplementedException(); } - } - } -} \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -8,8 +8,8 @@ { public class Registry : IDisposable { - private List<IExpression> _expressions = new List<IExpression>(); - private PluginGraph _graph; + private readonly List<IExpression> _expressions = new List<IExpression>(); + private readonly PluginGraph _graph; public Registry(PluginGraph graph) : this() { @@ -22,7 +22,15 @@ configure(); } + #region IDisposable Members + public void Dispose() + { + ConfigurePluginGraph(_graph); + } + + #endregion + /// <summary> /// Implement this method to /// </summary> @@ -50,11 +58,6 @@ } - public void Dispose() - { - ConfigurePluginGraph(_graph); - } - /// <summary> /// Direct StructureMap to build instances of type T, and look for concrete classes /// marked with the [Pluggable] attribute that implement type T @@ -232,43 +235,54 @@ public void RegisterInterceptor(TypeInterceptor interceptor) { - addExpression(delegate (PluginGraph pluginGraph) - { - pluginGraph.InterceptorLibrary.AddInterceptor(interceptor); - }); + addExpression( + delegate(PluginGraph pluginGraph) { pluginGraph.InterceptorLibrary.AddInterceptor(interceptor); }); } - public TypeInterceptorExpression IfTypeMatches(TypeMatchDelegate match) + public TypeInterceptorExpression IfTypeMatches(Predicate<Type> match) { TypeInterceptorExpression expression = new TypeInterceptorExpression(match); _expressions.Add(expression); return expression; } + + + /// <summary> + /// Programmatically determine Assembly's to be scanned for attribute configuration + /// </summary> + /// <returns></returns> + public ScanAssembliesExpression ScanAssemblies() + { + ScanAssembliesExpression expression = new ScanAssembliesExpression(this); + addExpression(expression); + + return expression; + } } - public delegate object InterceptionDelegate(object instance); - public delegate bool TypeMatchDelegate(Type type); + public class TypeInterceptorExpression : IExpression, TypeInterceptor { - private readonly TypeMatchDelegate _match; + private readonly Predicate<Type> _match; private InterceptionDelegate _interception; - internal TypeInterceptorExpression(TypeMatchDelegate match) + internal TypeInterceptorExpression(Predicate<Type> match) { _match = match; } + #region IExpression Members + void IExpression.Configure(PluginGraph graph) { graph.InterceptorLibrary.AddInterceptor(this); } - public void InterceptWith(InterceptionDelegate interception) - { - _interception = interception; - } + #endregion + #region TypeInterceptor Members + public bool MatchesType(Type type) { return _match(type); @@ -278,9 +292,17 @@ { return _interception(target); } + + #endregion + + public void InterceptWith(InterceptionDelegate interception) + { + _interception = interception; + } } internal delegate void PluginGraphAlteration(PluginGraph pluginGraph); + internal class BasicExpression : IExpression { private readonly PluginGraphAlteration _alteration; @@ -290,9 +312,13 @@ _alteration = alteration; } + #region IExpression Members + public void Configure(PluginGraph graph) { _alteration(graph); } + + #endregion } } \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Reflection; -using System.Threading; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Expression that directs StructureMap to scan the named assemblies - /// for [PluginFamily] and [Plugin] attributes - /// </summary> - public class ScanAssembliesExpression : IExpression - { - private List<AssemblyGraph> _assemblies = new List<AssemblyGraph>(); - - void IExpression.Configure(PluginGraph graph) - { - foreach (AssemblyGraph assembly in _assemblies) - { - graph.Assemblies.Add(assembly); - } - } - - public ScanAssembliesExpression IncludeTheCallingAssembly() - { - Assembly callingAssembly = findTheCallingAssembly(); - - if (callingAssembly != null) - { - _assemblies.Add(new AssemblyGraph(callingAssembly)); - } - - return this; - } - - private static Assembly findTheCallingAssembly() - { - StackTrace trace = new StackTrace(Thread.CurrentThread, false); - - Assembly thisAssembly = Assembly.GetExecutingAssembly(); - Assembly callingAssembly = null; - for (int i = 0; i < trace.FrameCount; i++) - { - StackFrame frame = trace.GetFrame(i); - Assembly assembly = frame.GetMethod().DeclaringType.Assembly; - if (assembly != thisAssembly) - { - callingAssembly = assembly; - break; - } - } - return callingAssembly; - } - - public ScanAssembliesExpression IncludeAssemblyContainingType<T>() - { - _assemblies.Add(AssemblyGraph.ContainingType<T>()); - - return this; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/DSL/UserControlExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/UserControlExpression.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/DSL/UserControlExpression.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,45 +0,0 @@ -using System; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - public class UserControlExpression : MementoBuilder<UserControlExpression> - { - private UserControlMemento _memento; - - public UserControlExpression(Type pluginType, string url) : base(pluginType) - { - _memento.Url = url; - } - - protected override InstanceMemento memento - { - get { return _memento; } - } - - protected override UserControlExpression thisInstance - { - get { return this; } - } - - protected override void configureMemento(PluginFamily family) - { - // no-op - } - - protected override void validate() - { - // no-op - } - - protected override void buildMemento() - { - _memento = new UserControlMemento(); - } - - public override void ValidatePluggability(Type pluginType) - { - // no-op - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Configuration/UserControlMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/UserControlMemento.cs 2008-01-14 04:24:37 UTC (rev 55) +++ trunk/Source/StructureMap/Configuration/UserControlMemento.cs 2008-01-15 15:15:50 UTC (rev 56) @@ -1,68 +0,0 @@ -using System; -using System.Web.UI; - -namespace StructureMap.Configuration -{ - public class UserControlMemento : InstanceMemento - { - private string _instanceKey; - private string _url; - - public UserControlMemento(string instanceKey, string url) - { - _instanceKey = instanceKey; - _url = url; - } - - - public UserControlMemento() - { - } - - public string Url - { - get { return _url; } - set { _url = value; } - } - - protected override object buildInstance(IInstanceCreator creator) - { - return new Page().LoadControl(_url); - } - - protected override string innerConcreteKey - { - get { return string.Empty; } - } - - protected override string innerInstanceKey - { - get { return _instanceKey; } - } - - protected override string getPropertyValue(string Key) - { - throw new NotImplementedException(); - } - - protected override InstanceMemento getChild(string Key) - { - throw new NotImplementedException(); - } - - public override InstanceMemento[] GetChildrenArray(string Key) - { - throw new NotImplementedException(); - } - - public override bool IsReference - { - get { return false; } - } - - public override string ReferenceKey - { - get { throw new NotImplementedException(); } - } - } -} \ No newline at end of file Added: trunk/Source/StructureMap/Delegates.c... [truncated message content] |