|
From: <jer...@us...> - 2008-04-06 16:26:11
|
Revision: 70
http://structuremap.svn.sourceforge.net/structuremap/?rev=70&view=rev
Author: jeremydmiller
Date: 2008-04-06 09:26:03 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
cleaning out trash code and reformatting code
Modified Paths:
--------------
trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs
trunk/Source/StructureMap/Configuration/FamilyParser.cs
trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
trunk/Source/StructureMap/Configuration/Mementos/ExplicitArgumentMemento.cs
trunk/Source/StructureMap/Configuration/Mementos/ExplicitArguments.cs
trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs
trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs
trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
trunk/Source/StructureMap/Graph/MachineOverride.cs
trunk/Source/StructureMap/Graph/Profile.cs
trunk/Source/StructureMap/IInstanceCreator.cs
trunk/Source/StructureMap/IPluginGraphSource.cs
trunk/Source/StructureMap/InstanceFactory.cs
trunk/Source/StructureMap/InstanceManager.cs
trunk/Source/StructureMap/MementoSource.cs
trunk/Source/StructureMap/ObjectFactory.cs
trunk/Source/StructureMap/PluginGraphBuilder.cs
trunk/Source/StructureMap/Properties/AssemblyInfo.cs
trunk/Source/StructureMap/Source/TemplatedMementoSource.cs
trunk/Source/StructureMap/Source/XmlAttributeInstanceMemento.cs
trunk/Source/StructureMap/Source/XmlTemplater.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap.AutoMocking/RhinoAutoMocker.cs
trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs
trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs
trunk/Source/StructureMap.Testing/Container/ExplicitArgumentTester.cs
trunk/Source/StructureMap.Testing/Container/FullStackFacadeTester.cs
trunk/Source/StructureMap.Testing/Container/InstanceManagerTester.cs
trunk/Source/StructureMap.Testing/Container/Interceptors/MockTypeInterceptor.cs
trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs
trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs
trunk/Source/StructureMap.Testing/TestData/DataMother.cs
Removed Paths:
-------------
trunk/Source/StructureMap/Configuration/DiagnosticGraphBuilder.cs
trunk/Source/StructureMap/Configuration/GraphObject.cs
trunk/Source/StructureMap/Configuration/GraphObjectIterator.cs
trunk/Source/StructureMap/Configuration/IConfigurationVisitor.cs
trunk/Source/StructureMap/Configuration/IInstanceValidator.cs
trunk/Source/StructureMap/Configuration/InstanceValidator.cs
trunk/Source/StructureMap/Configuration/PluginGraphReport.cs
trunk/Source/StructureMap/Configuration/ProblemFinder.cs
trunk/Source/StructureMap/Configuration/Tokens/
trunk/Source/StructureMap/DeploymentTasks/
trunk/Source/StructureMap/Graph/RemoteGraph.cs
trunk/Source/StructureMap/Graph/RemoteGraphContainer.cs
trunk/Source/StructureMap/Verification/
trunk/Source/StructureMap.DeploymentTasks/Deployment.cs
trunk/Source/StructureMap.DeploymentTasks/DumbConfigMergeTask.cs
trunk/Source/StructureMap.DeploymentTasks/ImportFamilyTask.cs
trunk/Source/StructureMap.DeploymentTasks/RemoveAssemblyTask.cs
trunk/Source/StructureMap.DeploymentTasks/Verification.cs
trunk/Source/StructureMap.Testing/Client/
trunk/Source/StructureMap.Testing/Configuration/DiagnosticGraphBuilderTester.cs
trunk/Source/StructureMap.Testing/Configuration/GraphObjectIteratorTester.cs
trunk/Source/StructureMap.Testing/Configuration/InstanceValidatorTester.cs
trunk/Source/StructureMap.Testing/Configuration/MockGraphObject.cs
trunk/Source/StructureMap.Testing/Configuration/PluginGraphReportTester.cs
trunk/Source/StructureMap.Testing/Configuration/Tokens/
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -3,7 +3,6 @@
using System.IO;
using System.Xml;
using StructureMap.Graph;
-using StructureMap.Graph.Configuration;
using StructureMap.Source;
namespace StructureMap.Configuration
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -10,9 +10,9 @@
public class ConfigurationParserCollection
{
private List<FetchNodeDelegate> _fetchers = new List<FetchNodeDelegate>();
+ private bool _ignoreDefaultFile = false;
private List<string> _otherFiles = new List<string>();
private bool _UseAndEnforceExistenceOfDefaultFile = false;
- private bool _ignoreDefaultFile = false;
public bool UseAndEnforceExistenceOfDefaultFile
{
@@ -33,7 +33,7 @@
// Pick up the configuration in the default StructureMap.config
string pathToStructureMapConfig = StructureMapConfiguration.GetStructureMapConfigurationPath();
- if ( (_UseAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig)) && !_ignoreDefaultFile)
+ if ((_UseAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig)) && !_ignoreDefaultFile)
{
addParsersFromFile(pathToStructureMapConfig, list);
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -25,10 +25,7 @@
protected override InstanceMemento memento
{
- get
- {
- return _memento;
- }
+ get { return _memento; }
}
protected override InstanceExpression thisInstance
Deleted: trunk/Source/StructureMap/Configuration/DiagnosticGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DiagnosticGraphBuilder.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/DiagnosticGraphBuilder.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,287 +0,0 @@
-using System;
-using StructureMap.Attributes;
-using StructureMap.Configuration.DSL;
-using StructureMap.Configuration.Tokens;
-using StructureMap.Graph;
-using StructureMap.Graph.Configuration;
-using StructureMap.Interceptors;
-
-namespace StructureMap.Configuration
-{
- public class DiagnosticGraphBuilder : IGraphBuilder
- {
- private NormalGraphBuilder _innerBuilder;
- private PluginGraphReport _report;
- private PluginGraphReport _systemReport;
- private InstanceValidator _systemValidator;
-
- public DiagnosticGraphBuilder(Registry[] registries)
- {
- _innerBuilder = new NormalGraphBuilder(registries);
- _systemReport = new PluginGraphReport();
- _report = new PluginGraphReport();
- }
-
- public PluginGraphReport Report
- {
- get { return _report; }
- }
-
- #region IGraphBuilder Members
-
- public PluginGraph PluginGraph
- {
- get { return _innerBuilder.PluginGraph; }
- }
-
- public void AddProfile(string profileName)
- {
- _innerBuilder.AddProfile(profileName);
- }
-
- public void OverrideProfile(string fullTypeName, string instanceKey)
- {
- _innerBuilder.OverrideProfile(fullTypeName, instanceKey);
- }
-
- public void AddMachine(string machineName, string profileName)
- {
- try
- {
- _innerBuilder.AddMachine(machineName, profileName);
- }
- catch (Exception e)
- {
- _report.LogProblem(new Problem("Could not add Machine", e));
- }
- }
-
- public void OverrideMachine(string fullTypeName, string instanceKey)
- {
- _innerBuilder.OverrideMachine(fullTypeName, instanceKey);
- }
-
- public TypePath LocateOrCreateFamilyForType(string fullName)
- {
- try
- {
- return _innerBuilder.LocateOrCreateFamilyForType(fullName);
- }
- catch (Exception e)
- {
- string message =
- string.Format("Could not find the implied type '{0}' in any of the designated Assemblies", fullName);
- _report.LogProblem(new Problem(message, e));
-
- return null;
- }
- }
-
- public void AddAssembly(string assemblyName, string[] deployableTargets)
- {
- AssemblyToken assemblyToken = new AssemblyToken(assemblyName, deployableTargets);
- _report.AddAssembly(assemblyToken);
- _systemReport.AddAssembly(assemblyToken);
-
- try
- {
- _innerBuilder.AddAssembly(assemblyName, deployableTargets);
- }
- catch (Exception ex)
- {
- assemblyToken.MarkLoadFailure(ex);
- }
- }
-
-
- public void StartFamilies()
- {
- _innerBuilder.StartFamilies();
- InstanceManager systemInstanceManager = new InstanceManager(_innerBuilder.SystemGraph);
- _systemValidator =
- new InstanceValidator(_innerBuilder.SystemGraph, new Profile("defaults"), systemInstanceManager);
- _systemReport.ImportImplicitChildren(SystemGraph);
- }
-
- public void AddPluginFamily(TypePath typePath, string defaultKey, string[] deploymentTargets,
- InstanceScope scope)
- {
- FamilyToken family = new FamilyToken(typePath, defaultKey, deploymentTargets);
- family.DefinitionSource = DefinitionSource.Explicit;
- family.Scope = scope;
- _report.AddFamily(family);
-
- try
- {
- Type type = typePath.FindType();
- _innerBuilder.AddPluginFamily(typePath, defaultKey, deploymentTargets, scope);
- }
- catch (Exception ex)
- {
- family.MarkAsInvalidType(ex);
- }
- }
-
-
- public void AttachSource(TypePath pluginTypePath, InstanceMemento sourceMemento)
- {
- FamilyToken family = _report.FindFamily(pluginTypePath);
-
- MementoSourceInstanceToken sourceInstance =
- new MementoSourceInstanceToken(typeof (MementoSource), _systemReport, sourceMemento);
- family.SourceInstance = sourceInstance;
- sourceInstance.Validate(_systemValidator);
-
- try
- {
- _innerBuilder.AttachSource(pluginTypePath, sourceMemento);
- }
- catch (Exception ex)
- {
- Problem problem = new Problem(ConfigurationConstants.COULD_NOT_CREATE_MEMENTO_SOURCE, ex);
- family.LogProblem(problem);
- }
- }
-
- public void AttachSource(TypePath pluginTypePath, MementoSource source)
- {
- _innerBuilder.AttachSource(pluginTypePath, source);
- }
-
- public Plugin AddPlugin(TypePath pluginTypePath, TypePath pluginPath, string concreteKey)
- {
- PluginToken pluginToken = new PluginToken(pluginPath, concreteKey, DefinitionSource.Explicit);
- FamilyToken familyToken = _report.FindFamily(pluginTypePath);
- familyToken.AddPlugin(pluginToken);
-
- Plugin returnValue = null;
-
- try
- {
- Plugin plugin = _innerBuilder.AddPlugin(pluginTypePath, pluginPath, concreteKey);
- pluginToken.ReadProperties(plugin);
- returnValue = plugin;
- }
- catch (StructureMapException ex)
- {
- if (ex.ErrorCode == 112)
- {
- Problem problem = new Problem(ConfigurationConstants.PLUGIN_IS_MISSING_CONCRETE_KEY, ex);
- pluginToken.LogProblem(problem);
- }
- else
- {
- Problem problem = new Problem(ConfigurationConstants.COULD_NOT_LOAD_TYPE, ex);
- pluginToken.LogProblem(problem);
- }
- }
- catch (Exception ex)
- {
- Problem problem = new Problem(ConfigurationConstants.UNKNOWN_PLUGIN_PROBLEM, ex);
- pluginToken.LogProblem(problem);
- }
-
- return returnValue;
- }
-
- public SetterProperty AddSetter(TypePath pluginTypePath, string concreteKey, string setterName)
- {
- FamilyToken familyToken = _report.FindFamily(pluginTypePath);
- PluginToken pluginToken = familyToken.FindPlugin(concreteKey);
-
- SetterProperty setter = null;
-
- try
- {
- setter = _innerBuilder.AddSetter(pluginTypePath, concreteKey, setterName);
- PropertyDefinition property = PropertyDefinitionBuilder.CreatePropertyDefinition(setter.Property);
- pluginToken.AddPropertyDefinition(property);
- }
- catch (Exception ex)
- {
- PropertyDefinition property =
- new PropertyDefinition(setterName, PropertyDefinitionType.Setter, ArgumentType.Primitive);
- pluginToken.AddPropertyDefinition(property);
- Problem problem = new Problem(ConfigurationConstants.INVALID_SETTER, ex);
-
- property.LogProblem(problem);
- }
-
- return setter;
- }
-
- public void AddInterceptor(TypePath pluginTypePath, InstanceMemento interceptorMemento)
- {
- InstanceToken instance =
- new InterceptorInstanceToken(typeof (InstanceFactoryInterceptor), _systemReport, interceptorMemento);
- instance.Validate(_systemValidator);
- FamilyToken family = _report.FindFamily(pluginTypePath);
- family.AddInterceptor(instance);
-
- try
- {
- _innerBuilder.AddInterceptor(pluginTypePath, interceptorMemento);
- }
- catch (Exception)
- {
- // no-op; The call above to instance.Validate(_systemValidator) will find the Problem
- }
- }
-
-
- public void FinishFamilies()
- {
- _innerBuilder.FinishFamilies();
- }
-
- public PluginGraph CreatePluginGraph()
- {
- PluginGraph pluginGraph = _innerBuilder.CreatePluginGraph();
- _report.ImportImplicitChildren(pluginGraph);
- _report.AnalyzeInstances(pluginGraph);
-
- Profile defaultProfile = _innerBuilder.DefaultManager.CalculateDefaults();
-
- InstanceManager manager = new InstanceManager();
- try
- {
- manager = new InstanceManager(pluginGraph);
- }
- catch (Exception ex)
- {
- Problem problem = new Problem(ConfigurationConstants.FATAL_ERROR, ex);
- _report.LogProblem(problem);
- }
-
- IInstanceValidator validator = new InstanceValidator(pluginGraph, defaultProfile, manager);
- _report.ValidateInstances(validator);
-
- return pluginGraph;
- }
-
- public PluginGraph SystemGraph
- {
- get { return _innerBuilder.SystemGraph; }
- }
-
- public InstanceDefaultManager DefaultManager
- {
- get { return _innerBuilder.DefaultManager; }
- }
-
- public void RegisterMemento(TypePath pluginTypePath, InstanceMemento memento)
- {
- try
- {
- _innerBuilder.RegisterMemento(pluginTypePath, memento);
- }
- catch (Exception ex)
- {
- Problem problem = new Problem(ConfigurationConstants.PLUGIN_FAMILY_CANNOT_BE_FOUND_FOR_INSTANCE, ex);
- _report.LogProblem(problem);
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -2,7 +2,6 @@
using System.Xml;
using StructureMap.Attributes;
using StructureMap.Graph;
-using StructureMap.Graph.Configuration;
using StructureMap.Source;
namespace StructureMap.Configuration
Deleted: trunk/Source/StructureMap/Configuration/GraphObject.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/GraphObject.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/GraphObject.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace StructureMap.Configuration
-{
- [Serializable]
- public abstract class GraphObject : IComparable
- {
- private Guid _id = Guid.NewGuid();
- private List<Problem> _problems = new List<Problem>();
-
- public GraphObject()
- {
- }
-
- public Guid Id
- {
- get { return _id; }
- set { _id = value; }
- }
-
- public Problem[] Problems
- {
- get { return _problems.ToArray(); }
- set { _problems = new List<Problem>(value); }
- }
-
- public virtual GraphObject[] Children
- {
- get { return new GraphObject[0]; }
- }
-
- protected abstract string key { get; }
-
- #region IComparable Members
-
- public int CompareTo(object obj)
- {
- GraphObject peer = (GraphObject) obj;
- return key.CompareTo(peer.key);
- }
-
- #endregion
-
- public void LogProblem(Problem problem)
- {
- _problems.Add(problem);
- }
-
- public virtual void AcceptVisitor(IConfigurationVisitor visitor)
- {
- // no-op
- }
- }
-}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Configuration/GraphObjectIterator.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/GraphObjectIterator.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/GraphObjectIterator.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,25 +0,0 @@
-namespace StructureMap.Configuration
-{
- public class GraphObjectIterator
- {
- private readonly IConfigurationVisitor _visitor;
-
- public GraphObjectIterator(IConfigurationVisitor visitor)
- {
- _visitor = visitor;
- }
-
- public void Visit(GraphObject startNode)
- {
- _visitor.StartObject(startNode);
- startNode.AcceptVisitor(_visitor);
-
- foreach (GraphObject child in startNode.Children)
- {
- Visit(child);
- }
-
- _visitor.EndObject(startNode);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Configuration/IConfigurationVisitor.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/IConfigurationVisitor.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/IConfigurationVisitor.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,28 +0,0 @@
-using StructureMap.Configuration.Tokens;
-using StructureMap.Configuration.Tokens.Properties;
-
-namespace StructureMap.Configuration
-{
- public interface IConfigurationVisitor
- {
- void StartObject(GraphObject node);
- void EndObject(GraphObject node);
-
- void HandleAssembly(AssemblyToken assembly);
- void HandleFamily(FamilyToken family);
- void HandleMementoSource(MementoSourceInstanceToken source);
- void HandlePlugin(PluginToken plugin);
- void HandleInterceptor(InterceptorInstanceToken interceptor);
- void HandleInstance(InstanceToken instance);
- void HandlePrimitiveProperty(PrimitiveProperty property);
- void HandleEnumerationProperty(EnumerationProperty property);
- void HandleInlineChildProperty(ChildProperty property);
- void HandleDefaultChildProperty(ChildProperty property);
- void HandleReferenceChildProperty(ChildProperty property);
- void HandlePropertyDefinition(PropertyDefinition propertyDefinition);
- void HandleChildArrayProperty(ChildArrayProperty property);
- void HandleNotDefinedChildProperty(ChildProperty property);
- void HandleTemplate(TemplateToken template);
- void HandleTemplateProperty(TemplateProperty property);
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,6 +1,7 @@
using StructureMap.Attributes;
+using StructureMap.Graph;
-namespace StructureMap.Graph.Configuration
+namespace StructureMap.Configuration
{
public interface IGraphBuilder
{
@@ -28,6 +29,7 @@
void OverrideProfile(string fullTypeName, string instanceKey);
void AddMachine(string machineName, string profileName);
void OverrideMachine(string fullTypeName, string instanceKey);
+
TypePath LocateOrCreateFamilyForType(string fullName);
}
}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Configuration/IInstanceValidator.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/IInstanceValidator.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/IInstanceValidator.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,11 +0,0 @@
-using System;
-
-namespace StructureMap.Configuration
-{
- public interface IInstanceValidator
- {
- object CreateObject(Type pluginType, InstanceMemento memento);
- bool HasDefaultInstance(Type pluginType);
- bool InstanceExists(Type pluginType, string instanceKey);
- }
-}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Configuration/InstanceValidator.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/InstanceValidator.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/InstanceValidator.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,59 +0,0 @@
-using System;
-using StructureMap.Graph;
-
-namespace StructureMap.Configuration
-{
- public class InstanceValidator : IInstanceValidator
- {
- private readonly Profile _defaultProfile;
- private readonly PluginGraph _pluginGraph;
- private InstanceManager _instanceManager;
-
- public InstanceValidator(PluginGraph pluginGraph, Profile defaultProfile, InstanceManager instanceManager)
- {
- if (defaultProfile == null)
- {
- throw new ArgumentNullException("defaultProfile", "Cannot be null");
- }
-
- _pluginGraph = pluginGraph;
- _defaultProfile = defaultProfile;
- _instanceManager = instanceManager;
- }
-
- #region IInstanceValidator Members
-
- public object CreateObject(Type pluginType, InstanceMemento memento)
- {
- return _instanceManager.CreateInstance(pluginType, memento);
- }
-
- public bool HasDefaultInstance(Type pluginType)
- {
- return _defaultProfile.HasOverride(TypePath.GetAssemblyQualifiedName(pluginType));
- }
-
- public bool InstanceExists(Type pluginType, string instanceKey)
- {
- bool returnValue = false;
-
- try
- {
- PluginFamily family = _pluginGraph.PluginFamilies[pluginType];
- InstanceMemento memento = family.Source.GetMemento(instanceKey);
- if (memento != null)
- {
- returnValue = true;
- }
- }
- catch (Exception)
- {
- returnValue = false;
- }
-
- return returnValue;
- }
-
- #endregion
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/Mementos/ExplicitArgumentMemento.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/Mementos/ExplicitArgumentMemento.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/Mementos/ExplicitArgumentMemento.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -14,16 +14,6 @@
}
- protected override object buildInstance(IInstanceCreator creator)
- {
- if (_inner == null)
- {
- _inner = creator.DefaultMemento;
- }
-
- return base.buildInstance(creator);
- }
-
protected override string innerConcreteKey
{
get { return _inner.ConcreteKey; }
@@ -44,6 +34,16 @@
get { return _inner.ReferenceKey; }
}
+ protected override object buildInstance(IInstanceCreator creator)
+ {
+ if (_inner == null)
+ {
+ _inner = creator.DefaultMemento;
+ }
+
+ return base.buildInstance(creator);
+ }
+
protected override string getPropertyValue(string Key)
{
return _args.GetArg(Key) ?? _inner.GetProperty(Key);
@@ -65,4 +65,4 @@
return _inner.GetChildrenArray(Key);
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/Mementos/ExplicitArguments.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/Mementos/ExplicitArguments.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/Mementos/ExplicitArguments.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -5,12 +5,12 @@
{
public class ExplicitArguments
{
+ private readonly Dictionary<string, string> _args = new Dictionary<string, string>();
private readonly Dictionary<Type, object> _children = new Dictionary<Type, object>();
- private readonly Dictionary<string, string> _args = new Dictionary<string, string>();
public T Get<T>() where T : class
{
- return (T) Get(typeof(T));
+ return (T) Get(typeof (T));
}
public object Get(Type type)
@@ -20,7 +20,7 @@
public void Set<T>(T arg)
{
- _children.Add(typeof(T), arg);
+ _children.Add(typeof (T), arg);
}
public void SetArg(string key, object argValue)
@@ -33,4 +33,4 @@
return _args.ContainsKey(key) ? _args[key] : null;
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -52,9 +52,9 @@
private readonly Hashtable _children = new Hashtable();
private readonly string _concreteKey;
+ private readonly NameValueCollection _properties = new NameValueCollection();
private string _instanceKey;
private bool _isReference;
- private readonly NameValueCollection _properties = new NameValueCollection();
private string _referenceKey;
@@ -66,7 +66,6 @@
public MemoryInstanceMemento(string concreteKey, string instanceKey)
: this(concreteKey, instanceKey, new NameValueCollection())
{
-
}
Modified: trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -3,7 +3,6 @@
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;
using StructureMap.Graph;
-using StructureMap.Graph.Configuration;
using StructureMap.Interceptors;
namespace StructureMap.Configuration
Deleted: trunk/Source/StructureMap/Configuration/PluginGraphReport.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/PluginGraphReport.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/PluginGraphReport.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,215 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using StructureMap.Configuration.Tokens;
-using StructureMap.Exceptions;
-using StructureMap.Graph;
-
-namespace StructureMap.Configuration
-{
- [Serializable]
- public class PluginGraphReport : GraphObject
- {
- private Hashtable _assemblies = new Hashtable();
- private InstanceDefaultManager _defaultManager;
- private Dictionary<TypePath, FamilyToken> _families = new Dictionary<TypePath, FamilyToken>();
-
- public PluginGraphReport()
- {
- }
-
- public PluginGraphReport(PluginGraph pluginGraph)
- {
- ReadFromPluginGraph(pluginGraph);
- }
-
- public override GraphObject[] Children
- {
- get
- {
- ArrayList list = new ArrayList();
-
- list.AddRange(_assemblies.Values);
- list.AddRange(_families.Values);
-
- list.Sort();
-
- return (GraphObject[]) list.ToArray(typeof (GraphObject));
- }
- }
-
- public InstanceDefaultManager DefaultManager
- {
- get { return _defaultManager; }
- set { _defaultManager = value; }
- }
-
- public AssemblyToken[] Assemblies
- {
- get
- {
- AssemblyToken[] returnValue = new AssemblyToken[_assemblies.Count];
- _assemblies.Values.CopyTo(returnValue, 0);
-
- return returnValue;
- }
- }
-
- public FamilyToken[] Families
- {
- get
- {
- FamilyToken[] returnValue = new FamilyToken[_families.Count];
- _families.Values.CopyTo(returnValue, 0);
-
-
- return returnValue;
- }
- }
-
- protected override string key
- {
- get { return string.Empty; }
- }
-
- public void ReadFromPluginGraph(PluginGraph pluginGraph)
- {
- ImportImplicitChildren(pluginGraph);
- AnalyzeInstances(pluginGraph);
-
- Profile defaultProfile = pluginGraph.DefaultManager.CalculateDefaults();
-
- InstanceManager manager = new InstanceManager();
- try
- {
- manager = new InstanceManager(pluginGraph);
- }
- catch (Exception ex)
- {
- Problem problem = new Problem(ConfigurationConstants.FATAL_ERROR, ex);
- LogProblem(problem);
- }
-
- IInstanceValidator validator = new InstanceValidator(pluginGraph, defaultProfile, manager);
- ValidateInstances(validator);
- }
-
- public void AddAssembly(AssemblyToken assemblyToken)
- {
- _assemblies.Add(assemblyToken.AssemblyName, assemblyToken);
- }
-
- public void AddFamily(FamilyToken family)
- {
- _families.Add(family.TypePath, family);
- }
-
- public FamilyToken FindFamily(string pluginTypeClassName)
- {
- TypePath path = TypePath.GetTypePath(pluginTypeClassName);
- if (path != null)
- {
- return FindFamily(path);
- }
-
- foreach (KeyValuePair<TypePath, FamilyToken> pair in _families)
- {
- if (pair.Key.Matches(pluginTypeClassName))
- {
- return pair.Value;
- }
- }
-
- return null;
- }
-
- public bool HasFamily(Type pluginType)
- {
- return _families.ContainsKey(new TypePath(pluginType));
- }
-
- public FamilyToken FindFamily(Type pluginType)
- {
- TypePath path = new TypePath(pluginType);
-
- if (!_families.ContainsKey(path))
- {
- throw new MissingPluginFamilyException(path.AssemblyQualifiedName);
- }
-
- return _families[path];
- }
-
-
- public PluginToken FindPlugin(TypePath pluginTypePath, string concreteKey)
- {
- return FindFamily(pluginTypePath).FindPlugin(concreteKey);
- }
-
- public PluginToken FindPlugin(Type pluginType, string concreteKey)
- {
- return FindPlugin(new TypePath(pluginType), concreteKey);
- }
-
- public void ImportImplicitChildren(PluginGraph pluginGraph)
- {
- foreach (PluginFamily family in pluginGraph.PluginFamilies)
- {
- if (family.DefinitionSource == DefinitionSource.Implicit)
- {
- FamilyToken token = FamilyToken.CreateImplicitFamily(family);
- AddFamily(token);
- }
-
- addImplicitPlugins(family);
- }
- }
-
- private void addImplicitPlugins(PluginFamily family)
- {
- FamilyToken familyToken = FindFamily(family.PluginType);
-
- foreach (Plugin plugin in family.Plugins)
- {
- if (plugin.DefinitionSource == DefinitionSource.Implicit)
- {
- PluginToken pluginToken = PluginToken.CreateImplicitToken(plugin);
- familyToken.AddPlugin(pluginToken);
- }
- }
- }
-
- public void AnalyzeInstances(PluginGraph pluginGraph)
- {
- foreach (PluginFamily family in pluginGraph.PluginFamilies)
- {
- FamilyToken token = FindFamily(family.PluginType);
- token.ReadInstances(family, this);
- }
- }
-
- public void ValidateInstances(IInstanceValidator validator)
- {
- foreach (FamilyToken family in _families.Values)
- {
- family.Validate(validator);
- }
- }
-
- public bool HasAssembly(string assemblyName)
- {
- return _assemblies.ContainsKey(assemblyName);
- }
-
- public TemplateToken FindTemplate(TypePath pluginTypePath, string templateName)
- {
- FamilyToken family = FindFamily(pluginTypePath);
- return family.FindTemplate(templateName);
- }
-
- public FamilyToken FindFamily(TypePath path)
- {
- return _families[path];
- }
- }
-}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Configuration/ProblemFinder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProblemFinder.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/ProblemFinder.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,178 +0,0 @@
-using System.Collections;
-using StructureMap.Configuration.Tokens;
-using StructureMap.Configuration.Tokens.Properties;
-using StructureMap.Graph;
-
-namespace StructureMap.Configuration
-{
- public class ProblemFinder : IConfigurationVisitor
- {
- private readonly PluginGraphReport _report;
- private Stack _graphPath = new Stack();
- private ArrayList _problems = new ArrayList();
-
- public ProblemFinder(PluginGraphReport report)
- {
- _report = report;
- }
-
- #region IConfigurationVisitor Members
-
- public void StartObject(GraphObject node)
- {
- _graphPath.Push(node.ToString());
-
- Problem[] problems = node.Problems;
- if (problems.Length > 0)
- {
- string path = buildPathString();
- foreach (Problem problem in problems)
- {
- problem.Path = path;
- problem.ObjectId = node.Id;
- }
-
- _problems.AddRange(problems);
- }
- }
-
- public void EndObject(GraphObject node)
- {
- _graphPath.Pop();
- }
-
- public void HandleAssembly(AssemblyToken assembly)
- {
- // no-op
- }
-
- public void HandleFamily(FamilyToken family)
- {
- // no-op
- }
-
- public void HandleMementoSource(MementoSourceInstanceToken source)
- {
- // no-op
- }
-
- public void HandlePlugin(PluginToken plugin)
- {
- // no-op
- }
-
- public void HandleInterceptor(InterceptorInstanceToken interceptor)
- {
- // no-op
- }
-
- public void HandleInstance(InstanceToken instance)
- {
- // no-op
- }
-
- public void HandlePrimitiveProperty(PrimitiveProperty property)
- {
- // no-op
- }
-
- public void HandleEnumerationProperty(EnumerationProperty property)
- {
- // no-op
- }
-
- public void HandleInlineChildProperty(ChildProperty property)
- {
- // no-op
- }
-
- public void HandleDefaultChildProperty(ChildProperty property)
- {
- // no-op
- }
-
- public void HandleReferenceChildProperty(ChildProperty property)
- {
- // no-op
- }
-
- public void HandlePropertyDefinition(PropertyDefinition propertyDefinition)
- {
- // no-op
- }
-
- public void HandleChildArrayProperty(ChildArrayProperty property)
- {
- // no-op
- }
-
- public void HandleNotDefinedChildProperty(ChildProperty property)
- {
- // no-op
- }
-
- public void HandleTemplate(TemplateToken template)
- {
- // no-op
- }
-
- public void HandleTemplateProperty(TemplateProperty property)
- {
- // no-op
- }
-
- #endregion
-
- public static Problem[] FindProblems(string configPath)
- {
- RemoteGraphContainer container = new RemoteGraphContainer(configPath);
- RemoteGraph remoteGraph = container.GetRemoteGraph();
- PluginGraphReport report = remoteGraph.GetReport();
- ProblemFinder finder = new ProblemFinder(report);
-
- return finder.GetProblems();
- }
-
- public static Problem[] FindProblems(string configPath, string binPath)
- {
- if (binPath == string.Empty || binPath == null)
- {
- return FindProblems(configPath);
- }
-
- RemoteGraphContainer container = new RemoteGraphContainer(configPath, binPath);
- RemoteGraph remoteGraph = container.GetRemoteGraph();
- PluginGraphReport report = remoteGraph.GetReport();
- ProblemFinder finder = new ProblemFinder(report);
-
- return finder.GetProblems();
- }
-
- public static Problem[] FindProblems(PluginGraphReport report)
- {
- ProblemFinder finder = new ProblemFinder(report);
- return finder.GetProblems();
- }
-
- public Problem[] GetProblems()
- {
- GraphObjectIterator iterator = new GraphObjectIterator(this);
- iterator.Visit(_report);
- return (Problem[]) _problems.ToArray(typeof (Problem));
- }
-
- private string buildPathString()
- {
- string pad = "";
- string path = "";
-
- foreach (object node in _graphPath)
- {
- path += pad + node + "\n";
- pad += " ";
- }
-
- return path;
- }
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,6 +1,5 @@
using System.Xml;
using StructureMap.Graph;
-using StructureMap.Graph.Configuration;
using StructureMap.Source;
namespace StructureMap.Configuration
Modified: trunk/Source/StructureMap/Graph/MachineOverride.cs
===================================================================
--- trunk/Source/StructureMap/Graph/MachineOverride.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Graph/MachineOverride.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using StructureMap.Configuration;
namespace StructureMap.Graph
{
@@ -122,6 +121,5 @@
{
return (_defaults.ContainsKey(pluginTypeName) || _profile.HasOverride(pluginTypeName));
}
-
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/Profile.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Profile.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Graph/Profile.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using StructureMap.Configuration;
namespace StructureMap.Graph
{
Deleted: trunk/Source/StructureMap/Graph/RemoteGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/RemoteGraph.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Graph/RemoteGraph.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,72 +0,0 @@
-using System;
-using System.Reflection;
-using StructureMap.Configuration;
-using StructureMap.DeploymentTasks;
-
-namespace StructureMap.Graph
-{
- /// <summary>
- /// Manages the setup and teardown of a new AppDomain to test a StructureMap configuration.
- /// </summary>
- public class RemoteGraph : MarshalByRefObject
- {
- private string _binPath;
- private string _configPath;
- private PluginGraph _pluginGraph;
- private PluginGraphReport _report;
-
- public RemoteGraph() : base()
- {
- }
-
- public string ConfigPath
- {
- get { return _configPath; }
- }
-
-
- public void Load(string configPath, string binPath)
- {
- _configPath = configPath;
- _binPath = binPath;
- AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
- }
-
- private void initializeChildren()
- {
- if (_pluginGraph != null)
- {
- return;
- }
-
- PluginGraphBuilder builder = new PluginGraphBuilder(_configPath);
- _pluginGraph = builder.BuildDiagnosticPluginGraph();
- _report = builder.Report;
- }
-
-
- public DeploymentExecutor CreateDeploymentExecutor()
- {
- return new DeploymentExecutor();
- }
-
- public PluginGraphReport GetReport()
- {
- initializeChildren();
- return _report;
- }
-
- public PluginGraph GetPluginGraph()
- {
- PluginGraphBuilder builder = new PluginGraphBuilder(_configPath);
- return builder.Build();
- }
-
-
- private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
- {
- string fileName = string.Format("{0}\\{1}.Dll", _binPath, args.Name);
- return Assembly.LoadFile(fileName);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/Source/StructureMap/Graph/RemoteGraphContainer.cs
===================================================================
--- trunk/Source/StructureMap/Graph/RemoteGraphContainer.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/Graph/RemoteGraphContainer.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,70 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-using System.Security.Policy;
-
-namespace StructureMap.Graph
-{
- /// <summary>
- /// Manages the setup and teardown of a new AppDomain to test a StructureMap configuration.
- /// </summary>
- [Serializable]
- public class RemoteGraphContainer : MarshalByRefObject
- {
- private readonly string _assembliesPath;
- private readonly string _configPath;
- private AppDomain _domain;
-
- public RemoteGraphContainer(string configPath, string binPath)
- {
- _configPath = Path.GetFullPath(configPath);
- _assembliesPath = Path.GetFullPath(binPath);
- }
-
- public RemoteGraphContainer(string configPath)
- {
- _configPath = Path.GetFullPath(configPath);
- _assembliesPath = Path.GetDirectoryName(_configPath);
- }
-
-
- public string BinPath
- {
- get { return _assembliesPath; }
- }
-
- public string ConfigPath
- {
- get { return _configPath; }
- }
-
-
- public RemoteGraph GetRemoteGraph()
- {
- AppDomainSetup setup = new AppDomainSetup();
- setup = new AppDomainSetup();
- setup.ApplicationBase = _assembliesPath;
-
- string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
- string binPath = Path.Combine(baseDirectory, "bin");
- setup.PrivateBinPath = _assembliesPath + ";" + baseDirectory + ";" + binPath;
-
-
- Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
- string domainName = "StructureMap-" + Guid.NewGuid().ToString();
- _domain = AppDomain.CreateDomain(domainName, evidence, setup);
-
-
- // Got to inject this copy of StructureMap.dll into new domain
- string assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
- Assembly assem = _domain.Load(assemblyName);
- object obj = _domain.CreateInstanceAndUnwrap(assemblyName, typeof (RemoteGraph).FullName);
-
- RemoteGraph graph = (RemoteGraph) obj;
-
- graph.Load(_configPath, _assembliesPath);
-
- return graph;
- }
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/IInstanceCreator.cs
===================================================================
--- trunk/Source/StructureMap/IInstanceCreator.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/IInstanceCreator.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -2,7 +2,7 @@
{
public interface IInstanceCreator
{
+ InstanceMemento DefaultMemento { get; }
object BuildInstance(InstanceMemento memento);
- InstanceMemento DefaultMemento{ get;}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/IPluginGraphSource.cs
===================================================================
--- trunk/Source/StructureMap/IPluginGraphSource.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/IPluginGraphSource.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -1,4 +1,3 @@
-using StructureMap.Configuration;
using StructureMap.Graph;
namespace StructureMap
Modified: trunk/Source/StructureMap/InstanceFactory.cs
===================================================================
--- trunk/Source/StructureMap/InstanceFactory.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/InstanceFactory.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -163,6 +163,11 @@
}
}
+ InstanceMemento IInstanceCreator.DefaultMemento
+ {
+ get { return _source.DefaultMemento; }
+ }
+
#endregion
#region IInstanceFactory Members
@@ -384,11 +389,5 @@
return memento;
}
-
-
- InstanceMemento IInstanceCreator.DefaultMemento
- {
- get { return _source.DefaultMemento; }
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/InstanceManager.cs
===================================================================
--- trunk/Source/StructureMap/InstanceManager.cs 2008-04-06 16:08:28 UTC (rev 69)
+++ trunk/Source/StructureMap/InstanceManager.cs 2008-04-06 16:26:03 UTC (rev 70)
@@ -160,14 +160,13 @@
{
ExplicitArgumentMemento memento = new ExplicitArgumentMemento(args, null);
return CreateInstance<PLUGINTYPE>(memento);
-
}
public void Inject<PLUGINTYPE>(PLUGINTYPE instance)
{
LiteralMemento memento = new LiteralMemento(instance);
AddInstance<PLUGINTYPE>(memento);
- SetDefault(typeof(PLUGINTYPE), memento);
+ SetDefault(typeof (PLUGINTYPE), memento);
}
public T CreateInstance<T>()
@@ -205,6 +204,152 @@
SetDefaults(defaultProfile);
}
+ /// <summary>
+ /// Creates the named instance of the PluginType
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <param name="instanceKey"></param>
+ /// <returns></returns>
+ public object CreateInstance(Type pluginType, string instanceKey)
+ {
+ IInstanceFactory instanceFactory = this[pluginType];
+ return instanceFactory.GetInstance(instanceKey);
+ }
+
+
+ /// <summary>
+ /// Creates a new object instance of the requested type
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <returns></returns>
+ public object CreateInstance(Type pluginType)
+ {
+ IInstanceFactory instanceFactory = this[pluginType];
+ return instanceFactory.GetInstance();
+ }
+
+
+ /// <summary>
+ /// Creates a new instance of the requested type using the InstanceMemento. Mostly used from other
+ /// classes to link children members
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <param name="instanceMemento"></param>
+ /// <returns></returns>
+ public object CreateInstance(Type pluginType, InstanceMemento instanceMemento)
+ {
+ IInstanceFactory instanceFactory = this[pluginType];
+ return instanceFactory.GetInstance(instanceMemento);
+ }
+
+ /// <summary>
+ /// Sets the default instance for the PluginType
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <param name="instanceMemento"></param>
+ public void SetDefault(Type pluginType, InstanceMemento instanceMemento)
+ {
+ IInstanceFactory instanceFactory = this[pluginType];
+ instanceFactory.SetDefault(instanceMemento);
+ }
+
+ /// <summary>
+ /// Sets the default instance for the PluginType
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <param name="instanceKey"></param>
+ public void SetDefault(Type pluginType, string instanceKey)
+ {
+ IInstanceFactory instanceFactory = this[pluginType];
+ instanceFactory.SetDefault(instanceKey);
+ }
+
+
+ /// <summary>
+ /// Sets the default instance for the PluginType
+ /// </summary>
+ /// <param name="pluginTypeName"></param>
+ /// <param name="instanceKey"></param>
+ public void SetDefault(string pluginTypeName, string instanceKey)
+ {
+ IInstanceFactory instanceFactory = this[pluginTypeName];
+ instanceFactory.SetDefault(instanceKey);
+ }
+
+
+ /// <summary>
+ /// Attempts to create a new instance of the requested type. Automatically inserts the default
+ /// configured instance for each dependency in the StructureMap constructor function.
+ /// </summary>
+ /// <param name="type"></param>
+ /// <returns></returns>
+ public object FillDependencies(Type type)
+ {
+ if (type.IsInterface || type.IsAbstract)
+ {
+ throw new StructureMapException(230);
+ }
+
+ IInstanceFactory factory = getOrCreateFactory(type);
+ return factory.GetInstance();
+ }
+
+ /// <summary>
+ /// Sets up the InstanceManager to return the object in the "stub" argument anytime
+ /// any instance of the PluginType is requested
+ /// </summary>
+ /// <param name="pluginType"></param>
+ /// <param name="stub"></param>
+ public void InjectStub(Type pluginType, object stub)
+ {
+ if (!Plugin.CanBeCast(pluginType, stub.GetType()))
+ {
+ throw new StructureMapException(220, pluginType.FullName,
+ stub.GetType().FullName);
+ }
+
+ LiteralMemento memento = new LiteralMemento(stub);
+ this[pluginType].SetDefault(memento);
+ }
+
+ public IList GetAllInstances(Type type)
+ {
+ return this[type].GetAllInstances();
+ }
+
+ public void AddInstance<T>(InstanceMemento memento)
+ {
+ IInstanceFactory factory = getOrCreateFactory(typeof (T), createFactory);
+ factory.AddInstance(memento);
+ }
+
+ public void AddInstance<PLUGINTYPE, CONCRETETYPE>()
+ {
+ IInstanceFactory factory = getOrCreateFactory(typeof (PLUGINTYPE), createFactory);
+ InstanceMemento memento = factory.AddType<CONCRETETYPE>();
+ factory.AddInstance(memento);
+ }
+
+ public void AddDefaultInstance<PLUGINTYPE, CONCRETETYPE>()
+ {
+ IInstanceFactory factory = getOrCreateFactory(typeof (PLUGINTYPE), createFactory);
+ InstanceMemento memento = factory.AddType<CONCRETETYPE>();
+ factory.SetDefault(memento);
+ }
+
+ public string WhatDoIHave()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ foreach (IInstanceFactory factory in this)
+ {
+ sb.AppendFormat("PluginType {0}, Default: {1}\r\n", factory.PluginType.AssemblyQualifiedName,
+ factory.DefaultInstanceKey);
+ }
+
+ return sb.ToString();
+ }
+
#endregion
private IInstanceFactory registerPluginFamily(PluginFamily family)
@@ -278,33 +423,8 @@
}
/// <summary>
- /// Creates the named instance of the PluginType
- /// </summary>
- /// <param name="pluginType"></param>
- /// <param name="instanceKey"></param>
- /// <returns></returns>
- public object CreateInstance(Type pluginType, string instanceKey)
- {
- IInstanceFactory instanceFactory = this[pluginType];
- return instanceFactory.GetInstance(instanceKey);
- }
-
-
-
- /// <summary>
/// Creates a new object instance of the requested type
/// </summary>
- /// <param name="pluginType"></param>
- /// <returns></returns>
- public object CreateInstance(Type pluginType)
- {
- IInstanceFactory instanceFactory = this[pluginType];
- return instanceFactory.GetInstance();
- }
-
- /// <summary>
- /// Creates a new object instance of the requested type
- /// </summary>
/// <param name="pluginTypeName">Fully qualified name of the CLR Type to create</param>
/// <returns></returns>
public object CreateInstance(string pluginTypeName)
@@ -326,21 +446,7 @@
return instanceFactory.GetInstance(instanceMemento);
}
-
/// <summary>
- /// Creates a new instance of the requested type using the InstanceMemento. Mostly used from other
- /// classes to link children members
- /// </summary>
- /// <param name="pluginType"></param>
- /// <param name="instanceMemento"></param>
- /// <returns></returns>
- public object CreateInstance(Type pluginType, InstanceMemento instanceMemento)
- {
- IInstanceFactory instanceFactory = this[pluginType];
- return instanceFactory.GetInstance(instanceMemento);
- }
-
- /// <summary>
/// Creates an array of object instances of the requested type
/// </summary>
/// <param name="pluginType"></param>
@@ -357,58 +463,6 @@
return instanceFactory.GetArray(instanceMementoes);
}
- /// <summary>
- /// Sets the default instance for the PluginType
- /// </summary>
- /// <param name="pluginType"></param>
- /// <param name="instanceMemento"></param>
- public void SetDefault(Type pluginType, InstanceMemento instanceMemento)
- {
- IInstanceFactory instanceFactory = this[pluginType];
- instanceFactory.SetDefault(instanceMemento);
- }
-
- /// <summary>
- /// Sets the default instance for the PluginType
- /// </summary>
- /// <param name="pluginType"></param>
- /// <param name="instanceKey"></param>
- public void SetDefault(Type pluginType, string instanceKey)
- {
- IInstanceFactory instanceFactory = this[pluginType];
- instanceFactory.SetDefault(instanceKey);
- }
-
-
- /// <summary>
- /// Sets the default instance for the PluginType
- /// </summary>
- /// <param name="pluginTypeName"></param>
- /// <param name="instanceKey"></param>
- public void SetDefault(string pluginTypeName, string instanceKey)
- {
- IInstanceFactory instanceFactory = this[pluginTypeName];
- instanceFactory.SetDefault(instanceKey);
- }
-
-
- /// <summary>
- /// Attempts to create a new instance of the requested type. Automatically inserts the default
- /// configured instance for each dependency in the StructureMap constructor function.
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public object FillDependencies(Type type)
- {
- if (type.IsInterface || type.IsAbstract)
- {
- t...
[truncated message content] |