Permalink
Browse files

last minute fixes for scanning, ObjectInstance.ConcreteType, PluginFa…

…mily.AddType()
  • Loading branch information...
jeremydmiller committed Dec 29, 2009
1 parent c0987db commit fa1929669cdc4755402f0353023c6c45f25eefb0
@@ -14,8 +14,12 @@ public void AutomaticallyFindRegistryFromAssembly()
{
ObjectFactory.Initialize(x =>
{
+ x.IgnoreStructureMapConfig = true;
+
x.Scan(s =>
{
+
+
s.AssemblyContainingType<RedGreenRegistry>();
s.LookForRegistries();
});
@@ -140,7 +140,6 @@ public GenericFamilyExpression Add(Instance instance)
/// <summary>
/// Configure this type as the supplied value
/// </summary>
- /// <param name="instance"></param>
/// <returns></returns>
public ObjectInstance Add(object @object)
{
@@ -294,11 +294,16 @@ public PluginFamily CreateTemplatedClone(Type[] templateTypes)
return templatedFamily;
}
+ private bool hasType(Type concreteType)
+ {
+ return FindPlugin(concreteType) != null || _instances.Any(x => x.ConcreteType == concreteType);
+ }
+
public void AddType(Type concreteType)
{
if (!concreteType.CanBeCastTo(_pluginType)) return;
- if (FindPlugin(concreteType) == null)
+ if (!hasType(concreteType))
{
AddPlugin(concreteType);
}
@@ -308,7 +313,7 @@ public void AddType(Type concreteType, string name)
{
if (!concreteType.CanBeCastTo(_pluginType)) return;
- if (FindPlugin(name) == null)
+ if (!hasType(concreteType))
{
AddPlugin(concreteType, name);
}
@@ -63,5 +63,10 @@ public override string ToString()
{
return string.Format("LiteralInstance: {0}", _object);
}
+
+ protected override Type getConcreteType(Type pluginType)
+ {
+ return _object.GetType();
+ }
}
}
@@ -10,7 +10,7 @@ namespace StructureMap.Query
public interface IModel
{
/// <summary>
- /// Access to all the <seealso cref="PluginTypeConfiguration">Plugin Type</seealso> registrations
+ /// Access to all the <seealso cref="IPluginTypeConfiguration">Plugin Type</seealso> registrations
/// </summary>
IEnumerable<IPluginTypeConfiguration> PluginTypes { get; }
@@ -35,14 +35,14 @@ public interface IModel
bool HasDefaultImplementationFor<T>();
/// <summary>
- /// Queryable access to all of the <see cref="IInstance">IInstance</see> for a given PluginType
+ /// Queryable access to all of the <see cref="InstanceRef">InstanceRef</see> for a given PluginType
/// </summary>
/// <param name="pluginType"></param>
/// <returns></returns>
IEnumerable<InstanceRef> InstancesOf(Type pluginType);
/// <summary>
- /// Queryable access to all of the <see cref="IInstance">IInstance</see> for a given PluginType
+ /// Queryable access to all of the <see cref="InstanceRef">InstanceRef</see> for a given PluginType
/// </summary>
/// <returns></returns>
IEnumerable<InstanceRef> InstancesOf<T>();

0 comments on commit fa19296

Please sign in to comment.