|
From: <jer...@us...> - 2007-03-25 02:43:21
|
Revision: 27
http://structuremap.svn.sourceforge.net/structuremap/?rev=27&view=rev
Author: jeremydmiller
Date: 2007-03-24 19:43:09 -0700 (Sat, 24 Mar 2007)
Log Message:
-----------
2.0 ifying, finishing up the Profile DSL support
Modified Paths:
--------------
trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs
trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs
trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs
trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
trunk/Source/StructureMap/Graph/Deployable.cs
trunk/Source/StructureMap/Graph/InstanceDefault.cs
trunk/Source/StructureMap/Graph/InstanceDefaultManager.cs
trunk/Source/StructureMap/Graph/MachineOverride.cs
trunk/Source/StructureMap/Graph/PluginFamily.cs
trunk/Source/StructureMap/Graph/Profile.cs
trunk/Source/StructureMap/InstanceManager.cs
trunk/Source/StructureMap/Interceptors/HttpContextItemInterceptor.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserTester.cs
trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
Added Paths:
-----------
trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs
trunk/Source/StructureMap.Testing/Sample.xml
Removed Paths:
-------------
trunk/Source/StructureMap/Configuration/DSL/DefaultExpression.cs
Deleted: trunk/Source/StructureMap/Configuration/DSL/DefaultExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/DefaultExpression.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/DefaultExpression.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,21 +0,0 @@
-using StructureMap.Graph;
-
-namespace StructureMap.Configuration.DSL
-{
- public delegate void ConfigurePluginGraph(PluginGraph graph);
-
- public class DefaultExpression : IExpression
- {
- private readonly ConfigurePluginGraph _configure;
-
- public DefaultExpression(ConfigurePluginGraph configure)
- {
- _configure = configure;
- }
-
- public void Configure(PluginGraph graph)
- {
- _configure(graph);
- }
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/IMementoBuilder.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -5,5 +5,7 @@
public interface IMementoBuilder
{
InstanceMemento BuildMemento(PluginFamily family);
+ InstanceMemento BuildMemento(PluginGraph graph);
+ void SetInstanceName(string instanceKey);
}
}
\ No newline at end of file
Added: trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs (rev 0)
+++ trunk/Source/StructureMap/Configuration/DSL/InstanceDefaultExpression.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -0,0 +1,56 @@
+using System;
+using StructureMap.Graph;
+
+namespace StructureMap.Configuration.DSL
+{
+ 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;
+ }
+
+ public ProfileExpression UseNamedInstance(string instanceKey)
+ {
+ _instanceKey = instanceKey;
+ return _parent;
+ }
+
+ public 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);
+ }
+
+ // TODO throw up!!!
+ }
+
+ public ProfileExpression Use(IMementoBuilder mementoBuilder)
+ {
+ _mementoBuilder = mementoBuilder;
+
+ return _parent;
+ }
+
+
+ }
+}
Modified: trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/MementoBuilder.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -9,6 +9,7 @@
{
protected readonly Type _pluginType;
protected List<IExpression> _children = new List<IExpression>();
+ private string _instanceKey = null;
public MementoBuilder(Type pluginType)
{
@@ -22,6 +23,12 @@
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)
@@ -59,11 +66,28 @@
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;
+ }
+
protected void addChildExpression(IExpression expression)
{
_children.Add(expression);
Modified: trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/ProfileExpression.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,13 +1,40 @@
using System;
+using System.Collections.Generic;
using StructureMap.Graph;
namespace StructureMap.Configuration.DSL
{
public class ProfileExpression : IExpression
{
- public void Configure(PluginGraph graph)
+ private readonly string _profileName;
+ private List<InstanceDefaultExpression> _defaults = new List<InstanceDefaultExpression>();
+
+ public ProfileExpression(string profileName)
{
- throw new NotImplementedException();
+ _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);
+ }
+ }
+
+ public InstanceDefaultExpression For<T>()
+ {
+ InstanceDefaultExpression defaultExpression = new InstanceDefaultExpression(typeof(T), this);
+ _defaults.Add(defaultExpression);
+
+ return defaultExpression;
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -65,9 +65,9 @@
public InstanceManager BuildInstanceManager()
{
- PluginGraph graph = new PluginGraph();
- configurePluginGraph(graph);
- return new InstanceManager(graph);
+ configurePluginGraph(_graph);
+ _graph.ReadDefaults();
+ return new InstanceManager(_graph);
}
public InstanceExpression AddInstanceOf<T>()
@@ -82,6 +82,11 @@
return new InstanceExpression(typeof (T));
}
+ public static PrototypeExpression<T> Prototype<T>(T prototype)
+ {
+ return new PrototypeExpression<T>(prototype);
+ }
+
public LiteralExpression<T> AddInstanceOf<T>(T target)
{
LiteralExpression<T> literal = new LiteralExpression<T>(target);
@@ -97,5 +102,13 @@
return expression;
}
+
+ public ProfileExpression CreateProfile(string profileName)
+ {
+ ProfileExpression expression = new ProfileExpression(profileName);
+ addExpression(expression);
+
+ return expression;
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/DSL/ScanAssembliesExpression.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -10,7 +10,7 @@
{
private List<AssemblyGraph> _assemblies = new List<AssemblyGraph>();
- public void Configure(PluginGraph graph)
+ void IExpression.Configure(PluginGraph graph)
{
foreach (AssemblyGraph assembly in _assemblies)
{
@@ -18,11 +18,6 @@
}
}
- public IExpression[] ChildExpressions
- {
- get { return new IExpression[0]; }
- }
-
public ScanAssembliesExpression IncludeTheCallingAssembly()
{
Assembly callingAssembly = findTheCallingAssembly();
Modified: trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -77,7 +77,7 @@
private void createOverrideInstance(string fullName, XmlElement instanceElement, WriteOverride function, string profileName)
{
- string key = profileName + "-Instance";
+ string key = Profile.InstanceKeyForProfile(profileName);
InstanceMemento memento = _creator.CreateMemento(instanceElement);
memento.InstanceKey = key;
Modified: trunk/Source/StructureMap/Graph/Deployable.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Deployable.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/Deployable.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,4 +1,4 @@
-using System.Collections;
+using System.Collections.Generic;
namespace StructureMap.Graph
{
@@ -10,11 +10,11 @@
{
public const string ALL = "All";
- private ArrayList _deploymentTargets;
+ private List<string> _deploymentTargets;
public Deployable()
{
- _deploymentTargets = new ArrayList();
+ _deploymentTargets = new List<string>();
}
public Deployable(string[] deploymentTargets) : this()
@@ -27,7 +27,7 @@
/// </summary>
public string[] DeploymentTargets
{
- get { return (string[]) _deploymentTargets.ToArray(typeof (string)); }
+ get { return _deploymentTargets.ToArray(); }
set
{
_deploymentTargets.Clear();
Modified: trunk/Source/StructureMap/Graph/InstanceDefault.cs
===================================================================
--- trunk/Source/StructureMap/Graph/InstanceDefault.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/InstanceDefault.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -19,6 +19,10 @@
_defaultKey = defaultKey;
}
+ public InstanceDefault(Type pluginType, string defaultKey) : this(pluginType.FullName, defaultKey)
+ {
+ }
+
public string PluginTypeName
{
get { return _pluginTypeName; }
Modified: trunk/Source/StructureMap/Graph/InstanceDefaultManager.cs
===================================================================
--- trunk/Source/StructureMap/Graph/InstanceDefaultManager.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/InstanceDefaultManager.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,5 +1,5 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
using StructureMap.Configuration;
namespace StructureMap.Graph
@@ -25,16 +25,16 @@
return machineName;
}
- private ArrayList _defaults;
- private Hashtable _machineOverrides;
- private Hashtable _profiles;
+ private List<InstanceDefault> _defaults;
+ private Dictionary<string, MachineOverride> _machineOverrides;
+ private Dictionary<string, Profile> _profiles;
private string _defaultProfileName = string.Empty;
public InstanceDefaultManager() : base()
{
- _defaults = new ArrayList();
- _machineOverrides = new Hashtable();
- _profiles = new Hashtable();
+ _defaults = new List<InstanceDefault>();
+ _machineOverrides = new Dictionary<string, MachineOverride>();
+ _profiles = new Dictionary<string, Profile>();
}
/// <summary>
@@ -49,9 +49,12 @@
public void ReadDefaultsFromPluginGraph(PluginGraph graph)
{
+ _defaults = new List<InstanceDefault>();
+
foreach (PluginFamily family in graph.PluginFamilies)
{
- AddPluginFamilyDefault(family.PluginType.FullName, family.DefaultInstanceKey);
+ InstanceDefault instanceDefault = new InstanceDefault(family.PluginType, family.DefaultInstanceKey);
+ _defaults.Add(instanceDefault);
}
}
@@ -106,7 +109,12 @@
/// <returns></returns>
public Profile GetProfile(string profileName)
{
- return _profiles[profileName] as Profile;
+ if (!_profiles.ContainsKey(profileName))
+ {
+ return null;
+ }
+
+ return _profiles[profileName];
}
/// <summary>
@@ -118,7 +126,7 @@
{
if (_machineOverrides.ContainsKey(machineName))
{
- return (MachineOverride) _machineOverrides[machineName];
+ return _machineOverrides[machineName];
}
else
{
@@ -133,7 +141,7 @@
if (_profiles.ContainsKey(profileToFind))
{
- return (Profile) _profiles[profileToFind];
+ return _profiles[profileToFind];
}
else
{
Modified: trunk/Source/StructureMap/Graph/MachineOverride.cs
===================================================================
--- trunk/Source/StructureMap/Graph/MachineOverride.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/MachineOverride.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
using StructureMap.Configuration;
using StructureMap.Configuration.Tokens;
@@ -14,7 +15,7 @@
{
private string _machineName;
private Profile _profile = new Profile(string.Empty);
- private Hashtable _defaults;
+ private Dictionary<string, InstanceDefault> _defaults;
public MachineOverride(string machineName, Profile profile)
: this(machineName)
@@ -28,7 +29,7 @@
public MachineOverride(string machineName) : base()
{
_machineName = machineName;
- _defaults = new Hashtable();
+ _defaults = new Dictionary<string, InstanceDefault>();
}
public string MachineName
@@ -71,7 +72,7 @@
}
else
{
- return ((InstanceDefault) _defaults[pluginTypeName]).DefaultKey;
+ return _defaults[pluginTypeName].DefaultKey;
}
}
}
Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamily.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -230,5 +230,10 @@
{
_plugins.RemoveImplicitChildren();
}
+
+ public void AddInstance(InstanceMemento memento)
+ {
+ _source.AddExternalMemento(memento);
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/Profile.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Profile.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Graph/Profile.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,5 +1,5 @@
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
using StructureMap.Configuration;
using StructureMap.Configuration.Tokens;
@@ -13,12 +13,12 @@
public class Profile : GraphObject
{
private string _profileName;
- private Hashtable _defaults;
+ private Dictionary<string, InstanceDefault> _defaults;
- public Profile(string profileName) : base()
+ public Profile(string profileName)
{
_profileName = profileName;
- _defaults = new Hashtable();
+ _defaults = new Dictionary<string, InstanceDefault>();
}
public string ProfileName
@@ -34,7 +34,7 @@
{
if (_defaults.ContainsKey(pluginTypeName))
{
- return ((InstanceDefault) _defaults[pluginTypeName]).DefaultKey;
+ return (_defaults[pluginTypeName]).DefaultKey;
}
else
{
@@ -129,5 +129,10 @@
{
get { return ProfileName; }
}
+
+ public static string InstanceKeyForProfile(string profileName)
+ {
+ return profileName + "-Instance";
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/InstanceManager.cs
===================================================================
--- trunk/Source/StructureMap/InstanceManager.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/InstanceManager.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -485,6 +485,18 @@
return this[type].GetAllInstances();
}
+ public IList<T> GetAllInstances<T>()
+ {
+ List<T> list = new List<T>();
+
+ foreach (T instance in this[typeof(T)].GetAllInstances())
+ {
+ list.Add(instance);
+ }
+
+ return list;
+ }
+
public void SetDefaultsToProfile(string profile)
{
// The authenticated user may not have required privileges to read from Environment
Modified: trunk/Source/StructureMap/Interceptors/HttpContextItemInterceptor.cs
===================================================================
--- trunk/Source/StructureMap/Interceptors/HttpContextItemInterceptor.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/Interceptors/HttpContextItemInterceptor.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -12,6 +12,7 @@
public HttpContextItemInterceptor() : base()
{
+
}
private string getKey(string instanceKey)
Modified: trunk/Source/StructureMap/StructureMap.csproj
===================================================================
--- trunk/Source/StructureMap/StructureMap.csproj 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap/StructureMap.csproj 2007-03-25 02:43:09 UTC (rev 27)
@@ -215,9 +215,9 @@
</Compile>
<Compile Include="Configuration\DSL\ChildInstanceExpression.cs" />
<Compile Include="Configuration\DSL\CreatePluginFamilyExpression.cs" />
- <Compile Include="Configuration\DSL\DefaultExpression.cs" />
<Compile Include="Configuration\DSL\IExpression.cs" />
<Compile Include="Configuration\DSL\IMementoBuilder.cs" />
+ <Compile Include="Configuration\DSL\InstanceDefaultExpression.cs" />
<Compile Include="Configuration\DSL\InstanceExpression.cs" />
<Compile Include="Configuration\DSL\LiteralExpression.cs" />
<Compile Include="Configuration\DSL\LiteralMemento.cs" />
Modified: trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserTester.cs 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserTester.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -1,3 +1,4 @@
+using System;
using System.Xml;
using NUnit.Framework;
using StructureMap.Configuration;
@@ -102,7 +103,8 @@
public void GotAllMachines()
{
string[] names = _defaults.GetMachineNames();
- Assert.AreEqual(new string[] {"SERVER", "GREEN-BOX"}, names);
+ Array.Sort(names);
+ Assert.AreEqual(new string[] {"GREEN-BOX", "SERVER" }, names);
}
[Test]
Added: trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs (rev 0)
+++ trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs 2007-03-25 02:43:09 UTC (rev 27)
@@ -0,0 +1,62 @@
+using NUnit.Framework;
+using Rhino.Mocks;
+using StructureMap.Configuration.DSL;
+using StructureMap.Graph;
+using StructureMap.Testing.Widget;
+
+namespace StructureMap.Testing.Configuration.DSL
+{
+ [TestFixture]
+ public class ProfileExpressionTester
+ {
+ [SetUp]
+ public void SetUp()
+ {
+
+ }
+
+ [Test]
+ public void AddAProfileWithANamedDefault()
+ {
+ string theProfileName = "TheProfile";
+ string theDefaultName = "TheDefaultName";
+
+ ProfileExpression expression = new ProfileExpression(theProfileName);
+
+ ProfileExpression expression2 = expression.For<IWidget>().UseNamedInstance(theDefaultName);
+ Assert.AreSame(expression, expression2);
+
+ PluginGraph graph = new PluginGraph();
+ ((IExpression)expression).Configure(graph);
+
+ Profile profile = graph.DefaultManager.GetProfile(theProfileName);
+ Assert.IsNotNull(profile);
+ Assert.AreEqual(new InstanceDefault[] { new InstanceDefault(typeof(IWidget), theDefaultName) }, profile.Defaults);
+ }
+
+ [Test]
+ public void AddAProfileWithInlineInstanceDefinition()
+ {
+ string theProfileName = "TheProfile";
+
+ PluginGraph graph = new PluginGraph();
+ Registry registry = new Registry(graph);
+ registry.CreateProfile(theProfileName)
+ .For<IWidget>().Use(
+ Registry.Instance<IWidget>().UsingConcreteType<AWidget>()
+ );
+
+ InstanceManager manager = registry.BuildInstanceManager();
+
+
+
+ Profile profile = manager.DefaultManager.GetProfile(theProfileName);
+ InstanceDefault instanceDefault = profile.Defaults[0];
+ Assert.AreEqual(Profile.InstanceKeyForProfile(theProfileName), instanceDefault.DefaultKey);
+
+ manager.SetDefaultsToProfile(theProfileName);
+ AWidget widget = (AWidget) manager.CreateInstance<IWidget>();
+ Assert.IsNotNull(widget);
+ }
+ }
+}
Added: trunk/Source/StructureMap.Testing/Sample.xml
===================================================================
--- trunk/Source/StructureMap.Testing/Sample.xml (rev 0)
+++ trunk/Source/StructureMap.Testing/Sample.xml 2007-03-25 02:43:09 UTC (rev 27)
@@ -0,0 +1,36 @@
+<StructureMap MementoStyle="Attribute" DefaultProfile="Development">
+ <Assembly Name="SomeAssembly"/>
+
+ <Profile Name="Production">
+ <Override Type="SomeAssembly.IService" DefaultKey="Production"/>
+ </Profile>
+
+ <Profile Name="Testing">
+ <Override Type="SomeAssembly.IService" DefaultKey="Testing"/>
+ </Profile>
+
+ <Profile Name="Development">
+ <Override Type="SomeAssembly.IService" DefaultKey="Development"/>
+ </Profile>
+
+
+ <PluginFamily Type="SomeAssembly.IService" Assembly="SomeAssembly">
+ <Plugin Type="SomeAssembly.ConcreteService" Assembly="SomeAssembly" ConcreteKey="Concrete"/>
+
+ <Instance Type="Concrete" Key="Production">
+ <Property Name="host" Value="PROD-SERVER"/>
+ <Property Name="port" Value="5050"/>
+ </Instance>
+
+ <Instance Type="Concrete" Key="Testing">
+ <Property Name="host" Value="TEST-SERVER"/>
+ <Property Name="port" Value="5050"/>
+ </Instance>
+
+ <Instance Type="Concrete" Key="Development">
+ <Property Name="host" Value="localhost"/>
+ <Property Name="port" Value="2000"/>
+ </Instance>
+ </PluginFamily>
+
+</StructureMap>
Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
===================================================================
--- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2007-03-08 11:51:48 UTC (rev 26)
+++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2007-03-25 02:43:09 UTC (rev 27)
@@ -189,6 +189,7 @@
<Compile Include="Configuration\DSL\CreateProfileTester.cs" />
<Compile Include="Configuration\DSL\InstanceExpressionTester.cs" />
<Compile Include="Configuration\DSL\LiteralExpressionTester.cs" />
+ <Compile Include="Configuration\DSL\ProfileExpressionTester.cs" />
<Compile Include="Configuration\DSL\RegistryTester.cs" />
<Compile Include="Configuration\DSL\ScanAssembliesTester.cs" />
<Compile Include="Configuration\FamilyParserTester.cs">
@@ -483,6 +484,9 @@
<ItemGroup>
<EmbeddedResource Include="TestData\InlineInstanceInProfileAndMachine.xml" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Sample.xml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|