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);
        }
示例#2
0
 public void Process(Type type, StructureMap.Configuration.DSL.Registry registry)
 {
     if (type.GetInterfaces().Contains(typeof(IModule)))
     {
         registry.AddType(typeof(IModule), type);
     }
 }
        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);
        }
示例#4
0
 public static Initialize()
 {
     StructureMap.Configuration.DSL.Registry registry = new StructureMap.Configuration.DSL.Registry();
     registry.For <IUser>().Use <User>();
     registry.For <IDatabase>().Use <Database>();
     registry.ForConcreteType <UserManagement>().Singleton();
     _container = new Container(registry);
 }
 public void Process(Type type, StructureMap.Configuration.DSL.Registry registry)
 {
 }
示例#6
0
 public Registry Initialise(Registry registry)
 {
     throw new System.NotImplementedException();
 }
示例#7
0
 public Registry Initialise(Registry registry)
 {
     throw new System.NotImplementedException();
 }