|
From: <jer...@us...> - 2008-12-21 16:31:52
|
Revision: 211
http://structuremap.svn.sourceforge.net/structuremap/?rev=211&view=rev
Author: jeremydmiller
Date: 2008-12-21 16:31:48 +0000 (Sun, 21 Dec 2008)
Log Message:
-----------
A performance enhancement to stop SM from needing to scan the StructureMap dll on startup
Modified Paths:
--------------
trunk/Source/CommonAssemblyInfo.cs
trunk/Source/StructureMap/Configuration/GraphBuilder.cs
trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
trunk/Source/StructureMap/MementoSource.cs
trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs
trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs
trunk/Source/StructureMap/PluginGraphBuilder.cs
trunk/Source/StructureMap/Source/DirectoryXmlMementoSource.cs
trunk/Source/StructureMap/Source/EmbeddedFolderXmlMementoSource.cs
trunk/Source/StructureMap/Source/MemoryMementoSource.cs
trunk/Source/StructureMap/Source/SingleEmbeddedXmlMementoSource.cs
trunk/Source/StructureMap/Source/TemplatedMementoSource.cs
trunk/Source/StructureMap/Source/XmlAttributeFileMementoSource.cs
trunk/Source/StructureMap/Source/XmlFileMementoSource.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs
trunk/Source/StructureMap.sln
Added Paths:
-----------
trunk/Source/StructureMap/SystemRegistry.cs
Modified: trunk/Source/CommonAssemblyInfo.cs
===================================================================
--- trunk/Source/CommonAssemblyInfo.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/CommonAssemblyInfo.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -13,11 +13,11 @@
//------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
-[assembly: AssemblyVersionAttribute("2.5.0.0000")]
+[assembly: AssemblyVersionAttribute("2.5.1.0000")]
[assembly: AssemblyCopyrightAttribute("Copyright (c) 2003-2008, Jeremy D. Miller")]
[assembly: AssemblyProductAttribute("StructureMap")]
[assembly: AssemblyCompanyAttribute("")]
[assembly: AssemblyConfigurationAttribute("release")]
-[assembly: AssemblyInformationalVersionAttribute("2.5.0.0000")]
-[assembly: AssemblyFileVersionAttribute("2.5.0.0000")]
+[assembly: AssemblyInformationalVersionAttribute("2.5.1.0000")]
+[assembly: AssemblyFileVersionAttribute("2.5.1.0000")]
Modified: trunk/Source/StructureMap/Configuration/GraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Reflection;
using StructureMap.Configuration.DSL;
using StructureMap.Graph;
@@ -10,10 +11,9 @@
{
private readonly AssemblyScanner _assemblyScanner;
private readonly PluginGraph _pluginGraph;
- private readonly PluginGraph _systemGraph;
- private readonly AssemblyScanner _systemScanner;
private Profile _profile;
private Container _systemContainer;
+ private readonly PluginGraph _systemGraph;
public GraphBuilder(Registry[] registries) : this(registries, new PluginGraph())
@@ -31,10 +31,8 @@
registry.ConfigurePluginGraph(_pluginGraph);
}
- _systemScanner = new AssemblyScanner();
- _systemScanner.Assembly(Assembly.GetExecutingAssembly());
-
- _systemGraph = new PluginGraph(_systemScanner);
+ _systemGraph = new SystemRegistry().Build();
+ _systemContainer = new Container(_systemGraph);
}
#region IGraphBuilder Members
@@ -44,11 +42,6 @@
_pluginGraph.Seal();
}
- public PluginGraph SystemGraph
- {
- get { return _systemGraph; }
- }
-
public PluginGraph PluginGraph
{
get { return _pluginGraph; }
@@ -60,7 +53,6 @@
{
Assembly assembly = AppDomain.CurrentDomain.Load(assemblyName);
_assemblyScanner.Assembly(assembly);
- _systemScanner.Assembly(assembly);
}
catch (Exception ex)
{
@@ -68,11 +60,6 @@
}
}
- public void PrepareSystemObjects()
- {
- _systemGraph.Seal();
- }
-
public IProfileBuilder GetProfileBuilder()
{
return new ProfileBuilder(_pluginGraph);
@@ -116,12 +103,6 @@
private object buildSystemObject(Type type, InstanceMemento memento)
{
Instance instance = memento.ReadInstance(_systemGraph, type);
-
- if (_systemContainer == null)
- {
- _systemContainer = new Container(_systemGraph);
- }
-
return _systemContainer.GetInstance(type, instance);
}
}
Modified: trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -15,11 +15,9 @@
public interface IGraphBuilder
{
- PluginGraph SystemGraph { get; }
PluginGraph PluginGraph { get; }
void AddAssembly(string assemblyName);
- void PrepareSystemObjects();
void FinishFamilies();
IProfileBuilder GetProfileBuilder();
Modified: trunk/Source/StructureMap/MementoSource.cs
===================================================================
--- trunk/Source/StructureMap/MementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/MementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -10,7 +10,6 @@
/// Abstract class that is the supertype of all storage and retrieval mechanisms of
/// InstanceMemento instances
/// </summary>
- [PluginFamily]
public abstract class MementoSource
{
private readonly Dictionary<string, InstanceMemento> _externalMementos =
Modified: trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -3,7 +3,6 @@
/// <summary>
/// Plugin interface to create custom build or lifecycle policies for a Plugin Type
/// </summary>
- [PluginFamily]
public interface IBuildInterceptor : IBuildPolicy
{
IBuildPolicy InnerPolicy { get; set; }
Modified: trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -2,7 +2,6 @@
namespace StructureMap.Pipeline
{
- [Pluggable("Singleton")]
public class SingletonPolicy : CacheInterceptor
{
private readonly object _locker = new object();
Modified: trunk/Source/StructureMap/PluginGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/PluginGraphBuilder.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/PluginGraphBuilder.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -64,8 +64,6 @@
p.ParseAssemblies(graphBuilder);
});
- graphBuilder.PrepareSystemObjects();
-
forAllParsers(p => p.Parse(graphBuilder));
_graph.Seal();
Modified: trunk/Source/StructureMap/Source/DirectoryXmlMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/DirectoryXmlMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/DirectoryXmlMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -11,7 +11,6 @@
/// DirectoryXmlMementoSource is meant to simplify complicated object graph configurations by isolating each instance to a separate
/// editable file.
/// </summary>
- [Pluggable("DirectoryXml")]
public class DirectoryXmlMementoSource : MementoSource
{
private readonly string _directory;
Modified: trunk/Source/StructureMap/Source/EmbeddedFolderXmlMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/EmbeddedFolderXmlMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/EmbeddedFolderXmlMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -7,7 +7,6 @@
namespace StructureMap.Source
{
- [Pluggable("EmbeddedXmlFolder")]
public class EmbeddedFolderXmlMementoSource : MementoSource
{
private readonly string _assemblyName;
Modified: trunk/Source/StructureMap/Source/MemoryMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -5,7 +5,6 @@
/// <summary>
/// An in-memory MementoSource
/// </summary>
- [Pluggable("Default")]
public class MemoryMementoSource : MementoSource
{
private readonly Hashtable _mementos;
Modified: trunk/Source/StructureMap/Source/SingleEmbeddedXmlMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/SingleEmbeddedXmlMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/SingleEmbeddedXmlMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -4,7 +4,6 @@
namespace StructureMap.Source
{
- [Pluggable("EmbeddedXmlFile")]
public class SingleEmbeddedXmlMementoSource : XmlMementoSource
{
private readonly Assembly _assembly;
Modified: trunk/Source/StructureMap/Source/TemplatedMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/TemplatedMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/TemplatedMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -1,6 +1,5 @@
namespace StructureMap.Source
{
- [Pluggable("Templated")]
public class TemplatedMementoSource : MementoSource
{
private readonly MementoSource _innerSource;
Modified: trunk/Source/StructureMap/Source/XmlAttributeFileMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/XmlAttributeFileMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/XmlAttributeFileMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -3,7 +3,6 @@
/// <summary>
/// Stores Attribute-normalized InstanceMemento's in an external file
/// </summary>
- [Pluggable("XmlAttributeFile")]
public class XmlAttributeFileMementoSource : XmlFileMementoSource
{
public XmlAttributeFileMementoSource(string filePath, string xpath, string nodeName)
Modified: trunk/Source/StructureMap/Source/XmlFileMementoSource.cs
===================================================================
--- trunk/Source/StructureMap/Source/XmlFileMementoSource.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/Source/XmlFileMementoSource.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -8,7 +8,6 @@
/// Implementation of XmlMementoSource that reads InstanceMemento's from an external file.
/// Useful to break the StructureMap.config file into smaller pieces.
/// </summary>
- [Pluggable("XmlFile")]
public class XmlFileMementoSource : XmlMementoSource
{
private readonly string _filePath;
Modified: trunk/Source/StructureMap/StructureMap.csproj
===================================================================
--- trunk/Source/StructureMap/StructureMap.csproj 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap/StructureMap.csproj 2008-12-21 16:31:48 UTC (rev 211)
@@ -420,6 +420,7 @@
<Compile Include="Pipeline\SmartInstance.cs" />
<Compile Include="PluginTypeConfiguration.cs" />
<Compile Include="ReflectionHelper.cs" />
+ <Compile Include="SystemRegistry.cs" />
<Compile Include="Util\Cache.cs" />
</ItemGroup>
<ItemGroup>
Added: trunk/Source/StructureMap/SystemRegistry.cs
===================================================================
--- trunk/Source/StructureMap/SystemRegistry.cs (rev 0)
+++ trunk/Source/StructureMap/SystemRegistry.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -0,0 +1,41 @@
+using StructureMap.Attributes;
+using StructureMap.Configuration.DSL;
+using StructureMap.Pipeline;
+using StructureMap.Source;
+
+namespace StructureMap
+{
+ public class SystemRegistry : Registry
+ {
+ public SystemRegistry()
+ {
+ addExpression(graph => graph.AddType(typeof(MementoSource), typeof(XmlFileMementoSource), "XmlFile"));
+
+ ForRequestedType<MementoSource>().TheDefaultIsConcreteType<MemoryMementoSource>();
+ AddMementoSourceType<DirectoryXmlMementoSource>("DirectoryXml");
+ AddMementoSourceType<EmbeddedFolderXmlMementoSource>("EmbeddedXmlFolder");
+ AddMementoSourceType<SingleEmbeddedXmlMementoSource>("EmbeddedXmlFile");
+ AddMementoSourceType<TemplatedMementoSource>("Templated");
+ AddMementoSourceType<XmlAttributeFileMementoSource>("XmlAttributeFile");
+ AddMementoSourceType<XmlFileMementoSource>("XmlFile");
+
+
+ AddInterceptorType<SingletonPolicy>(InstanceScope.Singleton);
+ AddInterceptorType<ThreadLocalStoragePolicy>(InstanceScope.ThreadLocal);
+ AddInterceptorType<HttpContextBuildPolicy>(InstanceScope.HttpContext);
+ AddInterceptorType<HttpSessionBuildPolicy>(InstanceScope.HttpSession);
+ AddInterceptorType<HybridBuildPolicy>(InstanceScope.Hybrid);
+
+ }
+
+ private void AddMementoSourceType<T>(string name)
+ {
+ addExpression(graph => graph.AddType(typeof(MementoSource), typeof(T), name));
+ }
+
+ private void AddInterceptorType<T>(InstanceScope scope)
+ {
+ addExpression(graph => graph.AddType(typeof(IBuildInterceptor), typeof(T), scope.ToString()));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2008-12-21 16:31:48 UTC (rev 211)
@@ -62,7 +62,6 @@
bool iWasCalled = false;
var builder = new GraphBuilder(new Registry[0]);
- builder.PrepareSystemObjects();
builder.WithSystemObject<IBuildInterceptor>(memento, "singleton", policy =>
{
Assert.IsInstanceOfType(typeof (SingletonPolicy), policy);
Modified: trunk/Source/StructureMap.sln
===================================================================
--- trunk/Source/StructureMap.sln 2008-12-21 00:37:33 UTC (rev 210)
+++ trunk/Source/StructureMap.sln 2008-12-21 16:31:48 UTC (rev 211)
@@ -27,8 +27,6 @@
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Widgets", "Widgets", "{E1C10209-160D-4054-ACB7-478A9FDCF84C}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GUI", "GUI", "{4F638ECF-2A69-4D6A-9B68-05CC40951217}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap", "StructureMap\StructureMap.csproj", "{3F36EA80-2F9A-4DAD-BA27-5AC6163A2EE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.Testing", "StructureMap.Testing\StructureMap.Testing.csproj", "{63C2742D-B6E2-484F-AFDB-346873075C5E}"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|