From: <fli...@us...> - 2009-10-08 16:44:21
|
Revision: 269 http://structuremap.svn.sourceforge.net/structuremap/?rev=269&view=rev Author: flimflan Date: 2009-10-08 16:44:14 +0000 (Thu, 08 Oct 2009) Log Message: ----------- Removed code that tried to parse ClassName/AssemblyName independently - just work with AssemblyQualifiedName directly - fixes bug when specifying assembly qualified generics in XML configuration Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/ExpressionValidator.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Configuration/FamilyParser.cs trunk/Source/StructureMap/Diagnostics/ValidationError.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Graph/TypePath.cs trunk/Source/StructureMap.Testing/Configuration/DictionaryAndArrayArgumentTester.cs trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs Modified: trunk/Source/StructureMap/Configuration/DSL/ExpressionValidator.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/ExpressionValidator.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Configuration/DSL/ExpressionValidator.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -32,8 +32,8 @@ { throw new StructureMapException( 303, - TypePath.GetAssemblyQualifiedName(_pluggedType), - TypePath.GetAssemblyQualifiedName(pluginType)); + _pluggedType.AssemblyQualifiedName, + pluginType.AssemblyQualifiedName); } } } Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -104,7 +104,7 @@ { if (graph.Registries.Contains(this)) return; - graph.Log.StartSource("Registry: " + TypePath.GetAssemblyQualifiedName(GetType())); + graph.Log.StartSource("Registry: " + GetType().AssemblyQualifiedName); _basicActions.ForEach(action => action()); _actions.ForEach(action => action(graph)); Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -94,7 +94,7 @@ InstanceMemento sourceMemento = new XmlAttributeInstanceMemento(node); string context = string.Format("MementoSource for {0}\n{1}", - TypePath.GetAssemblyQualifiedName(family.PluginType), node.OuterXml); + family.PluginType.AssemblyQualifiedName, node.OuterXml); _builder.WithSystemObject<MementoSource>(sourceMemento, context, source => family.AddMementoSource(source)); }); @@ -121,8 +121,7 @@ private void attachInterceptors(PluginFamily family, XmlElement familyElement) { - string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", - TypePath.GetAssemblyQualifiedName(family.PluginType)); + string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", family.PluginType.AssemblyQualifiedName); familyElement.ForEachChild("*/Interceptor").Do(element => { var interceptorMemento = new XmlAttributeInstanceMemento(element); Modified: trunk/Source/StructureMap/Diagnostics/ValidationError.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationError.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Diagnostics/ValidationError.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -29,7 +29,7 @@ writer.WriteLine( "-----------------------------------------------------------------------------------------------------"); writer.WriteLine("Validation Error in Method {0} of Instance '{1}' ({2})\n in PluginType {3}", MethodName, - Instance.Name, description, TypePath.GetAssemblyQualifiedName(PluginType)); + Instance.Name, description, PluginType.AssemblyQualifiedName); writer.WriteLine(); writer.WriteLine(Exception.ToString()); writer.WriteLine(); Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -218,7 +218,7 @@ { if (string.IsNullOrEmpty(memento.InstanceKey)) { - memento.InstanceKey = "DefaultInstanceOf" + TypePath.GetAssemblyQualifiedName(PluginType); + memento.InstanceKey = "DefaultInstanceOf" + PluginType.AssemblyQualifiedName; } AddInstance(memento); Modified: trunk/Source/StructureMap/Graph/TypePath.cs =================================================================== --- trunk/Source/StructureMap/Graph/TypePath.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap/Graph/TypePath.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -10,45 +10,23 @@ [Serializable] public class TypePath { - private readonly string _assemblyName = string.Empty; - private readonly string _className; - public TypePath(string assemblyName, string className) { - _className = className; - _assemblyName = assemblyName; + AssemblyQualifiedName = className + "," + assemblyName; } public TypePath(Type type) { - _className = type.FullName; - _assemblyName = type.Assembly.GetName().Name; + AssemblyQualifiedName = type.AssemblyQualifiedName; } public TypePath(string assemblyQualifiedName) { - string[] parts = assemblyQualifiedName.Split(','); - - _className = parts[0].Trim(); - - if (parts.Length > 1) _assemblyName = parts[1].Trim(); + AssemblyQualifiedName = assemblyQualifiedName; } - public string AssemblyQualifiedName - { - get { return _className + "," + _assemblyName; } - } + public string AssemblyQualifiedName { get; private set; } - public string AssemblyName - { - get { return _assemblyName; } - } - - public string ClassName - { - get { return _className; } - } - public static TypePath CreateFromXmlNode(XmlNode node) { string typeName = node.Attributes[XmlConstants.TYPE_ATTRIBUTE].Value; @@ -63,12 +41,6 @@ element.SetAttribute(XmlConstants.ASSEMBLY, type.Assembly.GetName().Name); } - public static string GetAssemblyQualifiedName(Type type) - { - var path = new TypePath(type); - return path.AssemblyQualifiedName; - } - public Type FindType() { try Modified: trunk/Source/StructureMap.Testing/Configuration/DictionaryAndArrayArgumentTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DictionaryAndArrayArgumentTester.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap.Testing/Configuration/DictionaryAndArrayArgumentTester.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -23,7 +23,7 @@ "; XmlElement element = DataMother.BuildDocument(xml).DocumentElement; - element.SetAttribute("PluggedType", TypePath.GetAssemblyQualifiedName(typeof (ClassWithStringAndIntArray))); + element.SetAttribute("PluggedType", typeof (ClassWithStringAndIntArray).AssemblyQualifiedName); var memento = new XmlAttributeInstanceMemento(element); var graph = new PluginGraph(); @@ -53,7 +53,7 @@ "; XmlElement element = DataMother.BuildDocument(xml).DocumentElement; - element.SetAttribute("PluggedType", TypePath.GetAssemblyQualifiedName(typeof (ClassWithDictionary))); + element.SetAttribute("PluggedType", typeof (ClassWithDictionary).AssemblyQualifiedName); var memento = new XmlNodeInstanceMemento(element, "Type", "Key"); @@ -84,7 +84,7 @@ "; XmlElement element = DataMother.BuildDocument(xml).DocumentElement; - element.SetAttribute("PluggedType", TypePath.GetAssemblyQualifiedName(typeof (ClassWithDictionary))); + element.SetAttribute("PluggedType", typeof (ClassWithDictionary).AssemblyQualifiedName); var memento = new XmlAttributeInstanceMemento(element); Modified: trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -154,7 +154,7 @@ { if (typeof (IBootstrapper).IsAssignableFrom(type)) { - Debug.WriteLine(TypePath.GetAssemblyQualifiedName(type)); + Debug.WriteLine(type.AssemblyQualifiedName); } } } Modified: trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -1,5 +1,7 @@ using NUnit.Framework; using StructureMap.Graph; +using StructureMap.Testing.GenericWidgets; +using StructureMap.Testing.Widget; namespace StructureMap.Testing.Graph { @@ -21,5 +23,15 @@ var path = new TypePath(GetType()); path.FindType(); } + + [Test] + public void can_parse_assembly_qualified_generics() + { + var sampleGenericType = typeof(IConcept<AWidget>); + var genericAssemblyQualifiedName = sampleGenericType.AssemblyQualifiedName; + + var path = new TypePath(genericAssemblyQualifiedName); + path.FindType().ShouldEqual(sampleGenericType); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2009-10-07 18:25:50 UTC (rev 268) +++ trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2009-10-08 16:44:14 UTC (rev 269) @@ -21,7 +21,7 @@ Type pluggedType = typeof (StubbedGateway); var values = new NameValueCollection(); - values.Add(XmlConstants.PLUGGED_TYPE, TypePath.GetAssemblyQualifiedName(pluggedType)); + values.Add(XmlConstants.PLUGGED_TYPE, pluggedType.AssemblyQualifiedName); _memento = new MemoryInstanceMemento(string.Empty, "Frank", values); _expectedPlugin = new Plugin(pluggedType); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |