From: <jer...@us...> - 2008-05-06 21:48:23
|
Revision: 94 http://structuremap.svn.sourceforge.net/structuremap/?rev=94&view=rev Author: jeremydmiller Date: 2008-05-06 14:48:18 -0700 (Tue, 06 May 2008) Log Message: ----------- Cleaning up unnecessary noise in PluggableAttribute and Plugin Modified Paths: -------------- trunk/Source/StructureMap/Attributes/PluggableAttribute.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/FamilyParser.cs trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs trunk/Source/StructureMap/Graph/Plugin.cs trunk/Source/StructureMap/Graph/PluginCollection.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Graph/TypePath.cs trunk/Source/StructureMap/InstanceBuilderList.cs trunk/Source/StructureMap/InstanceManager.cs trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs trunk/Source/StructureMap/Source/MemoryMementoSource.cs trunk/Source/StructureMap/Source/XmlFileMementoSource.cs trunk/Source/StructureMap.Testing/Container/EmittingTester.cs trunk/Source/StructureMap.Testing/Container/SetterInjectionEmittingTester.cs trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs trunk/Source/StructureMap.Testing/Graph/PluginTester.cs trunk/Source/StructureMap.Testing/Graph/SetterInjectionTester.cs trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs trunk/Source/StructureMap.Testing/InstanceMementoInstanceCreationTester.cs trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs trunk/Source/StructureMap.Testing.Widget/IWidget.cs trunk/Source/StructureMap.Testing.Widget/Rule.cs trunk/Source/StructureMap.Testing.Widget/WidgetMaker.cs trunk/Source/StructureMap.Testing.Widget2/DefaultRule.cs trunk/Source/StructureMap.Testing.Widget2/Rule1.cs trunk/Source/StructureMap.Testing.Widget3/Gateways.cs Modified: trunk/Source/StructureMap/Attributes/PluggableAttribute.cs =================================================================== --- trunk/Source/StructureMap/Attributes/PluggableAttribute.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Attributes/PluggableAttribute.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -9,18 +9,12 @@ public class PluggableAttribute : Attribute { private string _concreteKey; - private string _description; public PluggableAttribute(string concreteKey) - : this(concreteKey, string.Empty) { + _concreteKey = concreteKey; } - public PluggableAttribute(string TypeName, string Description) - { - _concreteKey = TypeName; - _description = Description; - } /// <summary> /// The ConcreteKey alias of the Type @@ -32,15 +26,6 @@ } /// <summary> - /// Description of the pluggable class type - /// </summary> - public string Description - { - get { return _description; } - set { _description = value; } - } - - /// <summary> /// Gets an instance of PluggableAttribute from a Type object /// </summary> /// <param name="objectType"></param> Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -150,7 +150,7 @@ _alterations.Add( delegate(PluginFamily family) { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (CONCRETETYPE)); + Plugin plugin = new Plugin(typeof (CONCRETETYPE)); plugin.ConcreteKey = instanceName; family.Plugins.Add(plugin); } Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -119,8 +119,7 @@ string context = "creating a Plugin for " + family.PluginTypeName; _builder.WithType(pluginPath, context, delegate(Type pluggedType) { - Plugin plugin = - Plugin.CreateExplicitPlugin(pluggedType, concreteKey, ""); + Plugin plugin = new Plugin(pluggedType, concreteKey); family.Plugins.Add(plugin); foreach (XmlElement setterElement in pluginElement.ChildNodes) Modified: trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Configuration/Mementos/MemoryInstanceMemento.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -9,7 +9,7 @@ [Obsolete("Think this is unnecessary")] public class GenericMemento<T> : MemoryInstanceMemento { public GenericMemento(string instanceKey) - : base(Plugin.CreateImplicitPlugin(typeof (T)).ConcreteKey, instanceKey) + : base(new Plugin(typeof (T)).ConcreteKey, instanceKey) { } } Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -6,7 +6,7 @@ { public class GenericsPluginGraph { - private Dictionary<Type, PluginFamily> _families; + private readonly Dictionary<Type, PluginFamily> _families; public GenericsPluginGraph() { @@ -15,12 +15,6 @@ public static bool CanBeCast(Type pluginType, Type pluggedType) { - //bool isGenericComparison = pluginType.IsGenericType && pluggedType.IsGenericType; - //if (!isGenericComparison) - //{ - // return false; - //} - try { return checkGenericType(pluggedType, pluginType); @@ -68,19 +62,6 @@ return false; } - public PluginFamily FindGenericFamily(string pluginTypeName) - { - foreach (KeyValuePair<Type, PluginFamily> pair in _families) - { - if (new TypePath(pair.Key).Matches(pluginTypeName)) - { - return pair.Value; - } - } - - return null; - } - public void AddFamily(PluginFamily family) { _families.Add(family.PluginType, family); Modified: trunk/Source/StructureMap/Graph/Plugin.cs =================================================================== --- trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -22,19 +22,7 @@ { #region static - public static Plugin CreateAutofilledPlugin(Type concreteType) - { - string pluginKey = Guid.NewGuid().ToString(); - Plugin plugin = CreateExplicitPlugin(concreteType, pluginKey, string.Empty); - if (!plugin.CanBeAutoFilled) - { - throw new StructureMapException(231); - } - return plugin; - } - - /// <summary> /// Determines if the PluggedType is a valid Plugin into the /// PluginType @@ -42,7 +30,7 @@ /// <param name="pluginType"></param> /// <param name="pluggedType"></param> /// <returns></returns> - public static bool IsAnExplicitPlugin(Type pluginType, Type pluggedType) + public static bool IsExplicitlyMarkedAsPlugin(Type pluginType, Type pluggedType) { bool returnValue = false; @@ -84,38 +72,6 @@ } - /// <summary> - /// Creates an Implicit Plugin that discovers its ConcreteKey from a [Pluggable] - /// attribute on the PluggedType - /// </summary> - /// <param name="pluggedType"></param> - /// <returns></returns> - public static Plugin CreateImplicitPlugin(Type pluggedType) - { - PluggableAttribute att = PluggableAttribute.InstanceOf(pluggedType); - if (att == null) - { - return - new Plugin(pluggedType, TypePath.GetAssemblyQualifiedName(pluggedType)); - } - else - { - return new Plugin(pluggedType, att.ConcreteKey); - } - } - - /// <summary> - /// Creates an Explicit Plugin for the pluggedType with the entered - /// concreteKey - /// </summary> - /// <param name="pluggedType"></param> - /// <param name="concreteKey"></param> - /// <param name="description"></param> - public static Plugin CreateExplicitPlugin(Type pluggedType, string concreteKey, string description) - { - return new Plugin(pluggedType, concreteKey); - } - public static ConstructorInfo GetGreediestConstructor(Type pluggedType) { ConstructorInfo returnValue = null; @@ -149,7 +105,7 @@ /// </summary> /// <param name="pluggedType"></param> /// <param name="concreteKey"></param> - private Plugin(Type pluggedType, string concreteKey) : base() + public Plugin(Type pluggedType, string concreteKey) : base() { if (concreteKey == string.Empty) { @@ -161,13 +117,23 @@ _setters = new SetterPropertyCollection(this); } + public Plugin(Type pluggedType) + { + PluggableAttribute att = PluggableAttribute.InstanceOf(pluggedType); + _concreteKey = att == null ? pluggedType.AssemblyQualifiedName : att.ConcreteKey; + + _pluggedType = pluggedType; + _setters = new SetterPropertyCollection(this); + + } + /// <summary> /// Troubleshooting constructor used by PluginGraphBuilder to find possible problems /// with the configured Plugin /// </summary> /// <param name="path"></param> /// <param name="concreteKey"></param> - public Plugin(TypePath path, string concreteKey) : base() + [Obsolete("Get rid of this. All of this should go through NormalGraphBuilder")] public Plugin(TypePath path, string concreteKey) : base() { if (concreteKey == string.Empty) { Modified: trunk/Source/StructureMap/Graph/PluginCollection.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -75,6 +75,7 @@ } } + [Obsolete("Get rid of this")] public void Add(TypePath path, string concreteKey) { Plugin plugin = new Plugin(path, concreteKey); @@ -87,9 +88,10 @@ /// <param name="pluggedType"></param> /// <param name="concreteKey"></param> // TODO -- not wild about this method. + [Obsolete("Get rid of this")] public void Add(Type pluggedType, string concreteKey) { - Plugin plugin = Plugin.CreateExplicitPlugin(pluggedType, concreteKey, string.Empty); + Plugin plugin = new Plugin(pluggedType, concreteKey); Add(plugin); } @@ -138,7 +140,7 @@ public Plugin FindOrCreate(Type pluggedType, bool createDefaultInstanceOfType) { - Plugin plugin = Plugin.CreateImplicitPlugin(pluggedType); + Plugin plugin = new Plugin(pluggedType); Add(plugin); return plugin; Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -44,7 +44,7 @@ PluginFamilyAttribute.ConfigureFamily(this); - _explicitlyMarkedPluginFilter = delegate(Type type) { return Plugin.IsAnExplicitPlugin(PluginType, type); }; + _explicitlyMarkedPluginFilter = delegate(Type type) { return Plugin.IsExplicitlyMarkedAsPlugin(PluginType, type); }; _implicitPluginFilter = delegate(Type type) { return Plugin.CanBeCast(PluginType, type); }; _pluginFilter = _explicitlyMarkedPluginFilter; } @@ -255,7 +255,7 @@ { if (!HasPlugin(pluggedType)) { - Plugin plugin = Plugin.CreateImplicitPlugin(pluggedType); + Plugin plugin = new Plugin(pluggedType); _plugins.Add(plugin); } } @@ -270,13 +270,13 @@ { if (!HasPlugin(pluggedType)) { - _plugins.Add(Plugin.CreateImplicitPlugin(pluggedType)); + _plugins.Add(new Plugin(pluggedType)); } } public void AddPlugin(Type pluggedType, string key) { - Plugin plugin = Plugin.CreateExplicitPlugin(pluggedType, key, string.Empty); + Plugin plugin = new Plugin(pluggedType, key); _plugins.Add(plugin); } Modified: trunk/Source/StructureMap/Graph/TypePath.cs =================================================================== --- trunk/Source/StructureMap/Graph/TypePath.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Graph/TypePath.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -53,16 +53,6 @@ get { return _className; } } - public static string GetTypeIdentifier(Type type) - { - return new TypePath(type).AssemblyQualifiedName; - } - - public static TypePath TypePathForFullName(string fullname) - { - return new TypePath(string.Empty, fullname); - } - public static TypePath CreateFromXmlNode(XmlNode node) { string typeName = node.Attributes[XmlConstants.TYPE_ATTRIBUTE].Value; @@ -96,16 +86,6 @@ } } - public bool Matches(string typeName) - { - return (AssemblyQualifiedName == typeName || ClassName == typeName); - } - - public bool Matches(Type type) - { - return (AssemblyQualifiedName == type.AssemblyQualifiedName || ClassName == type.FullName); - } - public override bool Equals(object obj) { TypePath peer = obj as TypePath; @@ -122,20 +102,6 @@ return AssemblyQualifiedName.GetHashCode(); } - - public bool CanFindType() - { - try - { - Type type = FindType(); - return true; - } - catch (Exception) - { - return false; - } - } - public override string ToString() { return AssemblyQualifiedName; Modified: trunk/Source/StructureMap/InstanceBuilderList.cs =================================================================== --- trunk/Source/StructureMap/InstanceBuilderList.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/InstanceBuilderList.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -29,7 +29,7 @@ // Add a missing PluggedType if we can if (Plugin.CanBeCast(_pluginType, pluggedType)) { - Plugin plugin = Plugin.CreateImplicitPlugin(pluggedType); + Plugin plugin = new Plugin(pluggedType); processPlugins(new Plugin[]{plugin}); return _builders[pluggedType]; Modified: trunk/Source/StructureMap/InstanceManager.cs =================================================================== --- trunk/Source/StructureMap/InstanceManager.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/InstanceManager.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -280,7 +280,7 @@ } // TODO: Little bit of smelliness here - Plugin plugin = Plugin.CreateImplicitPlugin(type); + Plugin plugin = new Plugin(type); if (!plugin.CanBeAutoFilled) { throw new StructureMapException(230, type.FullName); Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -223,7 +223,7 @@ private string findPropertyName<T>() { - Plugin plugin = Plugin.CreateImplicitPlugin(_pluggedType); + Plugin plugin = new Plugin(_pluggedType); string propertyName = plugin.FindFirstConstructorArgumentOfType<T>(); if (string.IsNullOrEmpty(propertyName)) Modified: trunk/Source/StructureMap/Source/MemoryMementoSource.cs =================================================================== --- trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -5,7 +5,7 @@ /// <summary> /// An in-memory MementoSource /// </summary> - [Pluggable("Default", "")] + [Pluggable("Default")] public class MemoryMementoSource : MementoSource { private Hashtable _mementos; Modified: trunk/Source/StructureMap/Source/XmlFileMementoSource.cs =================================================================== --- trunk/Source/StructureMap/Source/XmlFileMementoSource.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap/Source/XmlFileMementoSource.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -8,7 +8,7 @@ /// Implementation of XmlMementoSource that reads InstanceMemento's from an external file. /// Useful to break the StructureMap.config file into smaller pieces. /// </summary> - [Pluggable("XmlFile", "")] + [Pluggable("XmlFile")] public class XmlFileMementoSource : XmlMementoSource { private string _filePath; Modified: trunk/Source/StructureMap.Testing/Container/EmittingTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Container/EmittingTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/Container/EmittingTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -21,7 +21,7 @@ try { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); InstanceBuilderAssembly _InstanceBuilderAssembly = new InstanceBuilderAssembly("StructureMap.EmittingTesterAssembly", typeof (Rule)); Modified: trunk/Source/StructureMap.Testing/Container/SetterInjectionEmittingTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Container/SetterInjectionEmittingTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/Container/SetterInjectionEmittingTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -54,7 +54,7 @@ { PluginGraph graph = new PluginGraph(); PluginFamily family = graph.FindFamily(typeof (IGridColumn)); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof(EnumGridColumn)); + Plugin plugin = new Plugin(typeof(EnumGridColumn)); family.Plugins.Add(plugin); family.AddInstance(_source.GetMemento("Enum")); @@ -71,7 +71,7 @@ { PluginGraph graph = new PluginGraph(); PluginFamily family = graph.FindFamily(typeof(IGridColumn)); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof(LongGridColumn)); + Plugin plugin = new Plugin(typeof(LongGridColumn)); family.Plugins.Add(plugin); InstanceMemento memento = _source.GetMemento("Long"); @@ -90,7 +90,7 @@ { PluginGraph graph = new PluginGraph(); PluginFamily family = graph.FindFamily(typeof(IGridColumn)); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof(StringGridColumn)); + Plugin plugin = new Plugin(typeof(StringGridColumn)); family.Plugins.Add(plugin); InstanceMemento memento = _source.GetMemento("String"); Modified: trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -62,13 +62,13 @@ [Test] public void CanCreatePluginForGenericTypeWithGenericParameter() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (GenericService<int>), "key", string.Empty); + Plugin plugin = new Plugin(typeof (GenericService<int>), "key"); } [Test] public void CanCreatePluginForGenericTypeWithoutGenericParameter() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (GenericService<>), "key", string.Empty); + Plugin plugin = new Plugin(typeof (GenericService<>), "key"); } [Test, Ignore("Generics with more than 2 parameters")] Modified: trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -39,7 +39,7 @@ [Test] public void Plugin_can_service_a_generic_type() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof(SpecificConcept)); + Plugin plugin = new Plugin(typeof(SpecificConcept)); Assert.IsTrue(plugin.CanBePluggedIntoGenericType(typeof(IConcept<>), typeof(object))); Assert.IsFalse(plugin.CanBePluggedIntoGenericType(typeof(IConcept<>), typeof(string))); Assert.IsFalse(plugin.CanBePluggedIntoGenericType(typeof(IConcept<>), typeof(int))); Modified: trunk/Source/StructureMap.Testing/Graph/PluginTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/PluginTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/Graph/PluginTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -18,7 +18,7 @@ [SetUp] public void SetUp() { - _plugin = Plugin.CreateImplicitPlugin(typeof (ConfigurationWidget)); + _plugin = new Plugin(typeof (ConfigurationWidget)); _iwidget = typeof (IWidget); _widgetmaker = typeof (WidgetMaker); _colorwidget = typeof (ColorWidget); @@ -59,9 +59,16 @@ } [Test] + public void Get_concrete_key_from_attribute_if_it_exists() + { + Plugin plugin = new Plugin(typeof(ColorWidget)); + Assert.AreEqual("Color", plugin.ConcreteKey); + } + + [Test] public void CanBeAutoFilledIsFalse() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (GrandPrix)); + Plugin plugin = new Plugin(typeof (GrandPrix)); Assert.IsFalse(plugin.CanBeAutoFilled); } @@ -69,7 +76,7 @@ [Test] public void CanBeAutoFilledIsTrue() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (Mustang)); + Plugin plugin = new Plugin(typeof (Mustang)); Assert.IsTrue(plugin.CanBeAutoFilled); } @@ -94,14 +101,14 @@ [Test] public void CanMakeObjectInstanceActivator() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (DefaultGateway)); + Plugin plugin = new Plugin(typeof (DefaultGateway)); Assert.IsTrue(!plugin.HasConstructorArguments(), "DefaultGateway can be just an activator"); } [Test] public void CanNotMakeObjectInstanceActivator() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); Assert.IsTrue(plugin.HasConstructorArguments(), "ComplexRule cannot be just an activator"); } @@ -109,13 +116,13 @@ public void CanNotPluginWithoutAttribute() { string msg = "NotPluggableWidget cannot plug into IWidget automatically"; - Assert.AreEqual(false, Plugin.IsAnExplicitPlugin(_iwidget, typeof (NotPluggable)), msg); + Assert.AreEqual(false, Plugin.IsExplicitlyMarkedAsPlugin(_iwidget, typeof (NotPluggable)), msg); } [Test] public void CanPluginWithAttribute() { - Assert.AreEqual(true, Plugin.IsAnExplicitPlugin(_iwidget, _colorwidget), "ColorWidget plugs into IWidget"); + Assert.AreEqual(true, Plugin.IsExplicitlyMarkedAsPlugin(_iwidget, _colorwidget), "ColorWidget plugs into IWidget"); } @@ -144,7 +151,7 @@ [Test] public void CreateImplicitMementoWithNoConstructorArguments() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (DefaultGateway), "Default", string.Empty); + Plugin plugin = new Plugin(typeof (DefaultGateway), "Default"); InstanceMemento memento = plugin.CreateImplicitMemento(); Assert.IsNotNull(memento); @@ -155,7 +162,7 @@ [Test] public void CreateImplicitMementoWithSomeConstructorArgumentsReturnValueIsNull() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (Strategy), "Default", string.Empty); + Plugin plugin = new Plugin(typeof (Strategy), "Default"); InstanceMemento memento = plugin.CreateImplicitMemento(); Assert.IsNull(memento); } @@ -175,14 +182,14 @@ [Test] public void CreatePluginFromTypeThatDoesNotHaveAnAttributeDetermineTheConcreteKey() { - Plugin plugin = Plugin.CreateImplicitPlugin(GetType()); - Assert.AreEqual(TypePath.GetAssemblyQualifiedName(GetType()), plugin.ConcreteKey); + Plugin plugin = new Plugin(GetType()); + Assert.AreEqual(GetType().AssemblyQualifiedName, plugin.ConcreteKey); } [Test] public void CreatesAnImplicitMementoForAPluggedTypeThatCanBeAutoFilled() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (Mustang)); + Plugin plugin = new Plugin(typeof (Mustang)); InstanceMemento memento = plugin.CreateImplicitMemento(); Assert.IsNotNull(memento); @@ -193,7 +200,7 @@ [Test] public void DoesNotCreateAnImplicitMementoForAPluggedTypeThatCanBeAutoFilled() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (GrandPrix)); + Plugin plugin = new Plugin(typeof (GrandPrix)); InstanceMemento memento = plugin.CreateImplicitMemento(); Assert.IsNull(memento); @@ -202,7 +209,7 @@ [Test] public void FindFirstConstructorArgumentOfType() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (GrandPrix)); + Plugin plugin = new Plugin(typeof (GrandPrix)); string expected = "engine"; string actual = plugin.FindFirstConstructorArgumentOfType<IEngine>(); @@ -215,14 +222,14 @@ )] public void FindFirstConstructorArgumentOfTypeNegativeCase() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (GrandPrix)); + Plugin plugin = new Plugin(typeof (GrandPrix)); plugin.FindFirstConstructorArgumentOfType<IWidget>(); } [Test] public void GetFirstMarkedConstructor() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); ConstructorInfo constructor = plugin.GetConstructor(); Assert.IsNotNull(constructor); @@ -232,7 +239,7 @@ [Test] public void GetGreediestConstructor() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (GreaterThanRule)); + Plugin plugin = new Plugin(typeof (GreaterThanRule)); ConstructorInfo constructor = plugin.GetConstructor(); Assert.IsNotNull(constructor); @@ -257,7 +264,7 @@ { try { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ClassWithNoConstructor)); + Plugin plugin = new Plugin(typeof (ClassWithNoConstructor)); plugin.GetConstructor(); Assert.Fail("Should have thrown a StructureMapException"); } @@ -299,7 +306,7 @@ using (mocks.Playback()) { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (LotsOfStuff)); + Plugin plugin = new Plugin(typeof (LotsOfStuff)); plugin.VisitArguments(visitor); } } Modified: trunk/Source/StructureMap.Testing/Graph/SetterInjectionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/SetterInjectionTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/Graph/SetterInjectionTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -28,14 +28,14 @@ [Test] public void AutoFillDeterminationWithSetterPropertiesIsFalse() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (CannotBeAutoFilledGridColumn)); + Plugin plugin = new Plugin(typeof (CannotBeAutoFilledGridColumn)); Assert.IsFalse(plugin.CanBeAutoFilled); } [Test] public void AutoFillDeterminationWithSetterPropertiesIsTrue() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (AutoFilledGridColumn)); + Plugin plugin = new Plugin(typeof (AutoFilledGridColumn)); Assert.IsTrue(plugin.CanBeAutoFilled); } @@ -72,7 +72,7 @@ * WrapLines */ - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (BasicGridColumn)); + Plugin plugin = new Plugin(typeof (BasicGridColumn)); Assert.AreEqual(5, plugin.Setters.Count); Assert.IsTrue(plugin.Setters.Contains("Widget")); @@ -85,21 +85,21 @@ [Test, ExpectedException(typeof (StructureMapException))] public void TryToAddANonExistentSetterProperty() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (BasicGridColumn), "Basic", string.Empty); + Plugin plugin = new Plugin(typeof (BasicGridColumn), "Basic"); plugin.Setters.Add("NonExistentPropertyName"); } [Test, ExpectedException(typeof (StructureMapException))] public void TryToAddASetterPropertyThatDoesNotHaveASetter() { - Plugin plugin = Plugin.CreateExplicitPlugin(typeof (BasicGridColumn), "Basic", string.Empty); + Plugin plugin = new Plugin(typeof (BasicGridColumn), "Basic"); plugin.Setters.Add("HeaderText"); } [Test, ExpectedException(typeof (StructureMapException))] public void TryToCreateAnImplicitPluginWithASetterPropertyThatDoesNotHaveASetMethod() { - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (BadSetterClass)); + Plugin plugin = new Plugin(typeof (BadSetterClass)); } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/Graph/TypePathTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -23,14 +23,6 @@ } [Test] - public void CanFindType() - { - TypePath path = new TypePath(GetType().Assembly.GetName().Name, GetType().FullName); - Assert.IsTrue(path.CanFindType()); - Assert.IsNotNull(path.FindType()); - } - - [Test] public void Define_with_out_assembly_qualified_name_throws_exception() { try Modified: trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -26,7 +26,7 @@ values.Add(XmlConstants.PLUGGED_TYPE, TypePath.GetAssemblyQualifiedName(pluggedType)); _memento = new MemoryInstanceMemento(string.Empty, "Frank", values); - _expectedPlugin = Plugin.CreateImplicitPlugin(pluggedType); + _expectedPlugin = new Plugin(pluggedType); } #endregion Modified: trunk/Source/StructureMap.Testing/InstanceMementoInstanceCreationTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/InstanceMementoInstanceCreationTester.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing/InstanceMementoInstanceCreationTester.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -174,7 +174,7 @@ public void ReadChildArrayProperty() { PluginGraph graph = new PluginGraph(); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); graph.FindFamily(typeof (Rule)).Plugins.Add(plugin); @@ -207,7 +207,7 @@ public void ReadChildProperty_child_property_is_defined_build_child() { PluginGraph graph = new PluginGraph(); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); graph.FindFamily(typeof (Rule)).Plugins.Add(plugin); @@ -226,7 +226,7 @@ public void ReadChildProperty_child_property_is_not_defined_so_use_default() { PluginGraph graph = new PluginGraph(); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); graph.FindFamily(typeof (Rule)).Plugins.Add(plugin); @@ -241,7 +241,7 @@ public void ReadPrimitivePropertiesHappyPath() { PluginGraph graph = new PluginGraph(); - Plugin plugin = Plugin.CreateImplicitPlugin(typeof (ComplexRule)); + Plugin plugin = new Plugin(typeof (ComplexRule)); graph.FindFamily(typeof (Rule)).Plugins.Add(plugin); Modified: trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -7,7 +7,7 @@ int Count { get; } } - [Pluggable("String", "")] + [Pluggable("String")] public class StringList : IList { public string[] values; @@ -27,7 +27,7 @@ #endregion } - [Pluggable("Integer", "")] + [Pluggable("Integer")] public class IntegerList : IList { public int[] values; Modified: trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -2,7 +2,7 @@ namespace StructureMap.Testing.Widget { - [PluginFamily, Pluggable("Default", "")] + [PluginFamily, Pluggable("Default")] public class GrandChild { private int _BirthYear; @@ -26,7 +26,7 @@ } - [Pluggable("Leftie", "")] + [Pluggable("Leftie")] public class LeftieGrandChild : GrandChild { public LeftieGrandChild(int BirthYear) : base(false, BirthYear) @@ -35,7 +35,7 @@ } - [PluginFamily, Pluggable("Default", "")] + [PluginFamily, Pluggable("Default")] public class Child { private GrandChild _MyGrandChild; @@ -58,7 +58,7 @@ } } - [PluginFamily, Pluggable("Default", "")] + [PluginFamily, Pluggable("Default")] public class Parent { private int _Age; Modified: trunk/Source/StructureMap.Testing.Widget/IWidget.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/IWidget.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget/IWidget.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -7,7 +7,7 @@ void DoSomething(); } - [Pluggable("Color", "Only for testing")] + [Pluggable("Color")] public class ColorWidget : IWidget, ICloneable { private string _Color; @@ -97,7 +97,7 @@ #endregion } - [Pluggable("Money", "Only for testing")] + [Pluggable("Money")] public class MoneyWidget : IWidget { private double _Amount; @@ -120,7 +120,7 @@ } - [Pluggable("Configuration", "Only for testing")] + [Pluggable("Configuration")] public class ConfigurationWidget : IWidget { private bool _Bool; Modified: trunk/Source/StructureMap.Testing.Widget/Rule.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/Rule.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget/Rule.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -16,7 +16,7 @@ } } - [Pluggable("Complex", "Complex rule for testing")] + [Pluggable("Complex")] public class ComplexRule : Rule { private bool _Bool; @@ -111,7 +111,7 @@ } - [Pluggable("Color", "Color rule for testing")] + [Pluggable("Color")] public class ColorRule : Rule { private string _Color; @@ -130,7 +130,7 @@ } - [Pluggable("GreaterThan", "")] + [Pluggable("GreaterThan")] public class GreaterThanRule : Rule { private string _Attribute; Modified: trunk/Source/StructureMap.Testing.Widget/WidgetMaker.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/WidgetMaker.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget/WidgetMaker.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -6,7 +6,7 @@ public abstract IWidget MakeWidget(); } - [Pluggable("Color", "Only for testing")] + [Pluggable("Color")] public class ColorWidgetMaker : WidgetMaker { private string _Color; @@ -28,7 +28,7 @@ } } - [Pluggable("Money", "Only for testing")] + [Pluggable("Money")] public class MoneyWidgetMaker : WidgetMaker { private double _Amount; Modified: trunk/Source/StructureMap.Testing.Widget2/DefaultRule.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget2/DefaultRule.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget2/DefaultRule.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -2,7 +2,7 @@ namespace StructureMap.Testing.Widget2 { - [Pluggable("Default", "")] + [Pluggable("Default")] public class DefaultRule : Rule { public DefaultRule() Modified: trunk/Source/StructureMap.Testing.Widget2/Rule1.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget2/Rule1.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget2/Rule1.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -3,7 +3,7 @@ namespace StructureMap.Testing.Widget2 { - [Pluggable("Rule1", "")] + [Pluggable("Rule1")] public class Rule1 : Rule { public Rule1() Modified: trunk/Source/StructureMap.Testing.Widget3/Gateways.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget3/Gateways.cs 2008-05-06 20:33:10 UTC (rev 93) +++ trunk/Source/StructureMap.Testing.Widget3/Gateways.cs 2008-05-06 21:48:18 UTC (rev 94) @@ -9,7 +9,7 @@ void DoSomething(); } - [Pluggable("Default", "")] + [Pluggable("Default")] public class DefaultGateway : IGateway { private string _color; @@ -67,7 +67,7 @@ } - [Pluggable("Stubbed", "")] + [Pluggable("Stubbed")] public class StubbedGateway : IGateway { #region IGateway Members This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |