From: <jer...@us...> - 2008-04-06 19:02:31
|
Revision: 72 http://structuremap.svn.sourceforge.net/structuremap/?rev=72&view=rev Author: jeremydmiller Date: 2008-04-06 12:02:29 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Substituted in the IConfiguredInstance into the construction pipeline instead of InstanceMemento Modified Paths: -------------- trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs trunk/Source/StructureMap/Emitting/ClassBuilder.cs trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs trunk/Source/StructureMap/InstanceBuilder.cs trunk/Source/StructureMap/InstanceMemento.cs trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs trunk/Source/StructureMap.Testing.Widget/Decision.cs trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs trunk/Source/StructureMap.Testing.Widget5/BasicGridColumnInstanceBuilder.cs Modified: trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs =================================================================== --- trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -3,6 +3,7 @@ using System.Reflection.Emit; using StructureMap.Emitting.Parameters; using StructureMap.Graph; +using StructureMap.Pipeline; namespace StructureMap.Emitting { @@ -13,8 +14,8 @@ public class BuildInstanceMethod : Method { private readonly Plugin _plugin; - private ConstructorInfo _constructor; - private ParameterEmitter _parameterEmitter; + private readonly ConstructorInfo _constructor; + private readonly ParameterEmitter _parameterEmitter; public BuildInstanceMethod(Plugin plugin) : base() { @@ -32,7 +33,7 @@ public override Type[] ArgumentList { - get { return new Type[] {typeof (InstanceMemento)}; } + get { return new Type[] {typeof (IConfiguredInstance)}; } } public override string MethodName Modified: trunk/Source/StructureMap/Emitting/ClassBuilder.cs =================================================================== --- trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -13,13 +13,13 @@ private const TypeAttributes PUBLIC_ATTS = TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.BeforeFieldInit; - private string _ClassName; + private readonly string _className; - private ArrayList _Methods; - private TypeBuilder newTypeBuilder; - private Type superType; + private readonly ArrayList _methods; + private readonly TypeBuilder _newTypeBuilder; + private readonly Type _superType; - public ClassBuilder(ModuleBuilder module, string ClassName) : this(module, ClassName, typeof (Object)) + public ClassBuilder(ModuleBuilder module, string className) : this(module, className, typeof (Object)) { } @@ -27,11 +27,11 @@ { try { - _Methods = new ArrayList(); + _methods = new ArrayList(); - newTypeBuilder = module.DefineType(ClassName, PUBLIC_ATTS, superType); - this.superType = superType; - _ClassName = ClassName; + _newTypeBuilder = module.DefineType(ClassName, PUBLIC_ATTS, superType); + _superType = superType; + _className = ClassName; addDefaultConstructor(); } @@ -44,25 +44,25 @@ public string ClassName { - get { return _ClassName; } + get { return _className; } } public void AddMethod(Method method) { - _Methods.Add(method); - method.Attach(newTypeBuilder); + _methods.Add(method); + method.Attach(_newTypeBuilder); } internal void Bake() { - foreach (Method method in _Methods) + foreach (Method method in _methods) { method.Build(); } - newTypeBuilder.CreateType(); + _newTypeBuilder.CreateType(); } @@ -71,14 +71,14 @@ MethodAttributes atts = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName; - ConstructorBuilder construct = newTypeBuilder.DefineConstructor(atts, CallingConventions.Standard, null); + ConstructorBuilder construct = _newTypeBuilder.DefineConstructor(atts, CallingConventions.Standard, null); ILGenerator ilgen = construct.GetILGenerator(); ilgen.Emit(OpCodes.Ldarg_0); - ConstructorInfo constructor = superType.GetConstructor(new Type[0]); + ConstructorInfo constructor = _superType.GetConstructor(new Type[0]); ilgen.Emit(OpCodes.Call, constructor); ilgen.Emit(OpCodes.Ret); } @@ -87,7 +87,7 @@ public void AddReadonlyStringProperty(string PropertyName, string Value, bool Override) { PropertyBuilder prop = - newTypeBuilder.DefineProperty(PropertyName, PropertyAttributes.HasDefault, typeof (string), null); + _newTypeBuilder.DefineProperty(PropertyName, PropertyAttributes.HasDefault, typeof (string), null); MethodAttributes atts = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.Final | MethodAttributes.SpecialName; @@ -95,7 +95,7 @@ string _GetMethodName = "get_" + PropertyName; MethodBuilder methodGet = - newTypeBuilder.DefineMethod(_GetMethodName, atts, CallingConventions.Standard, typeof (string), null); + _newTypeBuilder.DefineMethod(_GetMethodName, atts, CallingConventions.Standard, typeof (string), null); ILGenerator gen = methodGet.GetILGenerator(); LocalBuilder ilReturn = gen.DeclareLocal(typeof (string)); Modified: trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs =================================================================== --- trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -1,6 +1,7 @@ using System; using System.Reflection; using System.Reflection.Emit; +using StructureMap.Pipeline; namespace StructureMap.Emitting.Parameters { @@ -11,12 +12,12 @@ /// </summary> public abstract class ParameterEmitter { - private ParameterEmitter _NextSibling; + private ParameterEmitter _nextSibling; protected ParameterEmitter NextSibling { - set { _NextSibling = value; } - get { return _NextSibling; } + set { _nextSibling = value; } + get { return _nextSibling; } } public void Generate(ILGenerator ilgen, ParameterInfo parameter) @@ -25,9 +26,9 @@ { generate(ilgen, parameter); } - else if (_NextSibling != null) + else if (_nextSibling != null) { - _NextSibling.Generate(ilgen, parameter); + _nextSibling.Generate(ilgen, parameter); } else { @@ -44,9 +45,9 @@ { generateSetter(ilgen, property); } - else if (_NextSibling != null) + else if (_nextSibling != null) { - _NextSibling.GenerateSetter(ilgen, property); + _nextSibling.GenerateSetter(ilgen, property); } else { @@ -72,9 +73,9 @@ protected abstract bool canProcess(Type parameterType); protected abstract void generate(ILGenerator ilgen, ParameterInfo parameter); - protected void callInstanceMemento(ILGenerator ilgen, string MethodName) + protected void callInstanceMemento(ILGenerator ilgen, string methodName) { - MethodInfo _method = typeof (InstanceMemento).GetMethod(MethodName); + MethodInfo _method = typeof (IConfiguredInstance).GetMethod(methodName); ilgen.Emit(OpCodes.Callvirt, _method); } Modified: trunk/Source/StructureMap/InstanceBuilder.cs =================================================================== --- trunk/Source/StructureMap/InstanceBuilder.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/InstanceBuilder.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -1,4 +1,5 @@ using System; +using StructureMap.Pipeline; namespace StructureMap { @@ -23,7 +24,7 @@ get { return _manager; } } - public abstract object BuildInstance(InstanceMemento memento); + public abstract object BuildInstance(IConfiguredInstance instance); public void SetInstanceManager(InstanceManager manager) { @@ -35,10 +36,5 @@ Type plugged = Type.GetType(PluggedType); return plugged.Equals(type); } - - //public Type GetPluggedType() - //{ - // return Type.GetType(PluggedType); - //} } } \ No newline at end of file Modified: trunk/Source/StructureMap/InstanceMemento.cs =================================================================== --- trunk/Source/StructureMap/InstanceMemento.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/InstanceMemento.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -2,13 +2,14 @@ using StructureMap.Configuration; using StructureMap.Graph; using StructureMap.Interceptors; +using StructureMap.Pipeline; namespace StructureMap { /// <summary> /// GoF Memento representing an Object Instance /// </summary> - public abstract class InstanceMemento + public abstract class InstanceMemento : IConfiguredInstance { public const string EMPTY_STRING = "STRING.EMPTY"; public const string SUBSTITUTIONS_ATTRIBUTE = "Substitutions"; Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -1,18 +1,16 @@ using System; -using System.Collections.Generic; -using System.Text; namespace StructureMap.Pipeline { public interface IConfiguredInstance { - + InstanceMemento[] GetChildrenArray(string propertyName); + string GetProperty(string propertyName); + object GetChild(string propertyName, string typeName, InstanceManager manager); } public class ConfiguredInstance : Instance { - - protected override T build<T>(IInstanceCreator creator) { throw new NotImplementedException(); @@ -28,4 +26,4 @@ throw new NotImplementedException(); } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -68,7 +68,7 @@ } - public override object BuildInstance(InstanceMemento memento) + public override object BuildInstance(IConfiguredInstance instance) { return null; } Modified: trunk/Source/StructureMap.Testing.Widget/Decision.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/Decision.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap.Testing.Widget/Decision.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -31,10 +31,10 @@ get { return null; } } - public override object BuildInstance(InstanceMemento memento) + public override object BuildInstance(IConfiguredInstance instance) { return new Decision( - (Rule[]) Manager.CreateInstanceArray("StructureMap.Testing.Widget", memento.GetChildrenArray("Rules"))); + (Rule[]) Manager.CreateInstanceArray("StructureMap.Testing.Widget", instance.GetChildrenArray("Rules"))); } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -108,7 +108,7 @@ } - public override object BuildInstance(InstanceMemento instance) + public override object BuildInstance(IConfiguredInstance instance) { return new Child( instance.GetProperty("Name"), Modified: trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -45,7 +45,7 @@ } - public override object BuildInstance(InstanceMemento instance) + public override object BuildInstance(IConfiguredInstance instance) { return new Cow( long.Parse(instance.GetProperty("Weight")), Modified: trunk/Source/StructureMap.Testing.Widget5/BasicGridColumnInstanceBuilder.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget5/BasicGridColumnInstanceBuilder.cs 2008-04-06 18:45:47 UTC (rev 71) +++ trunk/Source/StructureMap.Testing.Widget5/BasicGridColumnInstanceBuilder.cs 2008-04-06 19:02:29 UTC (rev 72) @@ -29,7 +29,7 @@ get { throw new NotImplementedException(); } } - public override object BuildInstance(InstanceMemento instance) + public override object BuildInstance(IConfiguredInstance instance) { BasicGridColumn column = new BasicGridColumn(instance.GetProperty("headerText")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |