void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
 {
     if (type.CanBeCastTo(typeof(UnityRegistry)) && type.CanBeCreated())
     {
         registry.AddRegistry((UnityRegistry)type.GetConstructor(Type.EmptyTypes).Invoke(null));
     }
 }
        public void Process(Type pType, IUnityRegistry pRegistry)
        {
            foreach (var lTypeInterface in this._typesInterfaces)
            {
                IEnumerable <Type> lTypesFrom = null;
                if (pType.CanBeCastTo(lTypeInterface))
                {
                    lTypesFrom = new[] { lTypeInterface };
                }
                else if (pType.ImplementsInterfaceTemplate(lTypeInterface))
                {
                    Type lInterface = lTypeInterface;
                    lTypesFrom = pType.GetInterfaces().Where(pI => pI.IsGenericType && pI.GetGenericTypeDefinition() == lInterface);
                }

                if (lTypesFrom == null)
                {
                    continue;
                }

                foreach (var lTypeFrom in lTypesFrom.Where(t => !t.CanBeCreated()))
                {
                    var lExpression = pRegistry.Register(lTypeFrom, pType).WithName(this._getName(pType));

                    if (this._lifetimePolicyAction != null)
                    {
                        this._lifetimePolicyAction(lExpression);
                    }
                }
            }
        }
 public void Process(Type pType, IUnityRegistry pRegistry)
 {
     if (pType.BaseType != null && pType.BaseType.IsAssignableFrom(typeof(ExoCommand)))
     {
         pRegistry.Register(pType, pType).AsSingleton();
     }
 }
Пример #4
0
 /// <summary>
 /// Register All interface from Xconso Namespace.
 /// </summary>
 /// <param name="pType"></param>
 /// <param name="pRegistry"></param>
 public void Process(Type pType, IUnityRegistry pRegistry)
 {
     foreach (var lInterface in pType.GetInterfaces().Where(pX => pX.Namespace != null && pX.Namespace.StartsWith("WS_Hotline")))
     {
         pRegistry.Register(lInterface, pType).AsSingleton();
     }
 }
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            Type @interface = FindInterface(type);

            if(@interface != null)
                registry.Register(@interface, type);
        }
 void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
 {
     if (type == typeof(FooService))
     {
         registry.Register <IFooService, FooService>().WithName("Custom");
     }
 }
Пример #7
0
 /// <summary>
 /// Register All interface from Xconso Namespace.
 /// </summary>
 /// <param name="pType"></param>
 /// <param name="pRegistry"></param>
 public void Process(Type pType, IUnityRegistry pRegistry)
 {
     if (pType.BaseType == typeof(ViewModelBase))
     {
         pRegistry.Register(pType, pType).AsSingleton();
     }
 }
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            Type @interface = FindInterface(type);

            if (@interface != null)
            {
                registry.Register(@interface, type);
            }
        }
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated())
                return;

            Type interfaceType = GetInterfaceType(type);

            if (interfaceType != null)
                registry.Register(interfaceType, type);
        }
Пример #10
0
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            IEnumerable <PropertyInfo> properties =
                type.GetProperties().Where(p => p.CanWrite && p.PropertyType == interfaceType);

            foreach (PropertyInfo property in properties)
            {
                registry.Register(null, type).WithInjectionMembers(new InjectionProperty(property.Name));
            }
        }
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            if (type.CanBeCastTo(interfaceType) && type.CanBeCreated())
            {
                var expression = registry.Register(interfaceType, type).WithName(getName(type));

                if (lifetimePolicyAction != null)
                {
                    lifetimePolicyAction(expression);
                }
            }
        }
Пример #12
0
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            if (!type.IsConcrete() || !type.CanBeCreated())
            {
                return;
            }

            Type interfaceType = GetInterfaceType(type);

            if (interfaceType != null)
            {
                registry.Register(interfaceType, type);
            }
        }
        void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
        {
            Type typeFrom = null;

            if (type.CanBeCastTo(interfaceType))
            {
                typeFrom = interfaceType;
            }
            else if (type.ImplementsInterfaceTemplate(interfaceType))
            {
                typeFrom = type.GetInterfaces().FirstOrDefault(i => i.GetGenericTypeDefinition() == interfaceType);
            }

            if (typeFrom != null && type.CanBeCreated())
            {
                var expression = registry.Register(typeFrom, type).WithName(getName(type));

                if (lifetimePolicyAction != null)
                {
                    lifetimePolicyAction(expression);
                }
            }
        }
 private void ApplyConventions(Type type, IUnityRegistry registry)
 {
     conventions.ForEach(c => c.Process(type, registry));
 }
 public void Scan(IUnityRegistry registry)
 {
     GetExportedTypes().ForEach(type => ApplyConventions(type, registry));
 }
 void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
 {
     if (type == typeof(FooService))
         registry.Register<IFooService, FooService>().WithName("Custom");
 }
 void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
 {
     if (type.CanBeCastTo(typeof(UnityRegistry)) && type.CanBeCreated())
         registry.AddRegistry((UnityRegistry) type.GetConstructor(Type.EmptyTypes).Invoke(null));
 }
Пример #18
0
 /// <summary> Построение корневого контейнера </summary>
 public static void BuildUp(IUnityRegistry registry)
 {
     BuildUp(new [] { registry });
 }