コード例 #1
0
        private void AddTypes(IEnumerable <Type> types, IoCRegistrationType registrationType)
        {
            foreach (var type in types)
            {
                if (registrationType == IoCRegistrationType.Manual)
                {
                    continue;
                }

                var implementing = type.GetImplementedInterfaces(true);

                if (registrationType == IoCRegistrationType.Transient)
                {
                    foreach (var implementedType in implementing)
                    {
                        AddTransient(implementedType, type);
                    }
                    AddTransient(type);
                    continue;
                }

                if (registrationType == IoCRegistrationType.Singleton)
                {
                    foreach (var implementedType in implementing)
                    {
                        AddSingleton(implementedType, type);
                    }
                    AddSingleton(type);
                }
            }
        }
コード例 #2
0
        protected IEnumerable <Type> AddSweep(Type inheritedFrom, IoCRegistrationType registrationType)
        {
            var types = _createableTypes.Inherits(inheritedFrom);

            AddTypes(types, registrationType);

            return(types);
        }
コード例 #3
0
        protected IEnumerable <Type> AddSweep(string kind, IoCRegistrationType registrationType)
        {
            var types = _createableTypes.EndingWith(kind);

            AddTypes(types, registrationType);

            return(types);
        }
コード例 #4
0
 protected IEnumerable <Type> AddSweep <T>(IoCRegistrationType registrationType) => AddSweep(typeof(T), registrationType);