public void Process(Type type, StructureMap.Configuration.DSL.Registry registry) { if (type.CanBeCastTo(typeof(Controller)) && !type.IsAbstract) { registry.For(type).LifecycleIs(new UniquePerRequestLifecycle()); } }
public void Process(Type type, StructureMap.Configuration.DSL.Registry registry) { if (!type.IsInterface) { return; } if (type.IsGenericTypeDefinition) { return; } Assembly containingAssembly = type.Assembly; var matchedType = containingAssembly.GetTypes() .Where(x => x.Namespace == type.Namespace && x.GetInterface(type.FullName) != null) .FirstOrDefault(); if (matchedType == null) { return; } registry.For(type).Use(matchedType); }
public void Process(Type type, StructureMap.Configuration.DSL.Registry registry) { if (type.IsAbstract) { return; } if (type.IsInterface) { return; } var originalInterface = type.GetInterfaces().Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == baseInterface).FirstOrDefault(); if (originalInterface == null) return; Type[] wrappedTypes = originalInterface.GetGenericArguments(); // Create the created type Type implementationType = baseInterface.MakeGenericType(wrappedTypes); // And specify what we're going to use registry.For(implementationType).Use(type); }
/* public override void Initialize(StructureMap.Graph.IAssemblyScanner scan) { base.Initialize(scan); } */ public override void Initialize(StructureMap.ConfigurationExpression config) { config.For<Script>().Use(() => Script.Load(ScriptPath)); }
public static void Cofigure(StructureMap.IInitializationExpression x) { x.For<IAccountRepository>().HttpContextScoped().Use<AccountRepository>(); }