From: <jer...@us...> - 2008-05-03 03:52:31
|
Revision: 86 http://structuremap.svn.sourceforge.net/structuremap/?rev=86&view=rev Author: jeremydmiller Date: 2008-05-02 20:52:25 -0700 (Fri, 02 May 2008) Log Message: ----------- Added some behavior to NormalGraphBuilder in preparation for a big refactoring to come Modified Paths: -------------- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs trunk/Source/StructureMap/Diagnostics/Tokens.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Modified: trunk/Source/StructureMap/Configuration/IGraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-05-03 03:24:24 UTC (rev 85) +++ trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-05-03 03:52:25 UTC (rev 86) @@ -24,15 +24,20 @@ void FinishFamilies(); PluginGraph CreatePluginGraph(); + + // All of these need to DIE! void AddPluginFamily(Type pluginType, string defaultKey, InstanceScope scope); void AttachSource(Type pluginType, InstanceMemento sourceMemento); void AttachSource(Type pluginType, MementoSource source); Plugin AddPlugin(Type pluginType, TypePath pluginPath, string concreteKey); SetterProperty AddSetter(Type pluginType, string concreteKey, string setterName); void AddInterceptor(Type pluginType, InstanceMemento interceptorMemento); - void RegisterMemento(Type pluginType, InstanceMemento memento); + + IProfileBuilder GetProfileBuilder(); + + void ConfigureFamily(TypePath pluginTypePath, Action<PluginFamily> action); } } \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs 2008-05-03 03:24:24 UTC (rev 85) +++ trunk/Source/StructureMap/Configuration/NormalGraphBuilder.cs 2008-05-03 03:52:25 UTC (rev 86) @@ -7,6 +7,9 @@ namespace StructureMap.Configuration { + // TODO: Kill in 3.5 + public delegate void Action<T>(T subject); + public class NormalGraphBuilder : IGraphBuilder { private readonly PluginGraph _pluginGraph; @@ -150,6 +153,20 @@ return new ProfileBuilder(_pluginGraph); } + public void ConfigureFamily(TypePath pluginTypePath, Action<PluginFamily> action) + { + try + { + Type pluginType = pluginTypePath.FindType(); + PluginFamily family = _pluginGraph.FindFamily(pluginType); + action(family); + } + catch (Exception ex) + { + _pluginGraph.Log.RegisterError(103, ex, pluginTypePath.ClassName, pluginTypePath.AssemblyName); + } + } + #endregion private object buildSystemObject(Type type, InstanceMemento memento) Modified: trunk/Source/StructureMap/Diagnostics/Tokens.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/Tokens.cs 2008-05-03 03:24:24 UTC (rev 85) +++ trunk/Source/StructureMap/Diagnostics/Tokens.cs 2008-05-03 03:52:25 UTC (rev 86) @@ -33,6 +33,13 @@ addError(error); } + public void RegisterError(int code, Exception ex, params object[] args) + { + Error error = new Error(code, ex, args); + addError(error); + } + + private void addError(Error error) { error.Source = _currentSource; @@ -53,6 +60,19 @@ throw new ApplicationException(msg); } } + + public void AssertHasError(int errorCode) + { + foreach (Error error in _errors) + { + if (error.Code == errorCode) + { + return; + } + } + + throw new ApplicationException("No error with code " + errorCode); + } } public class Source @@ -213,6 +233,18 @@ _message = string.Format(template, args); } + public Error(int errorCode, Exception ex, params object[] args) : this(errorCode, args) + { + _message += "\n\n" + ex.ToString(); + _stackTrace = ex.StackTrace; + } + + + public int Code + { + get { return _code; } + } + public Error(StructureMapException exception) { _code = exception.ErrorCode; Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2008-05-03 03:24:24 UTC (rev 85) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2008-05-03 03:52:25 UTC (rev 86) @@ -180,6 +180,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="Configuration\InlineInstanceDefinitionInProfileAndMachineNodesTester.cs" /> + <Compile Include="Configuration\NormalGraphBuilderTester.cs" /> <Compile Include="Configuration\ProfileBuilderTester.cs" /> <Compile Include="Configuration\ShortcuttedInstanceNodeTester.cs" /> <Compile Include="Container\ArrayConstructorTester.cs"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |