コード例 #1
0
ファイル: ServiceLocator.cs プロジェクト: stadub/Net.Utils
        public ILocatorResolutionInfo <TClass> RegisterType <TInterface, TClass>(string name) where TClass : TInterface
        {
            var interfaceType = typeof(TInterface);
            var classType     = typeof(TClass);

            if (interfaceType.IsGenericType || classType.IsGenericType)
            {
                throw new TypeNotSupportedException(interfaceType.FullName, "Generic Types cannot be registered by RegisterType registrationInfo registration");
            }

            var key = GetKey(interfaceType, name);

            CheckDuplicated(key);

            var propRegistrationInfo = new PropertyRegistrationInfo <TClass>();

            var typeBuilder = new LocatorTypeBuilder <TClass>(this, propRegistrationInfo);

            registeredTypes.AddOrUpdate(key, typeBuilder, (pair, builder) => typeBuilder);

            var registrationInfo = new LocatorRegistrationInfo <TClass>();

            registrationInfo.PropertyInjectionResolvers = typeBuilder.PropertyResolvers;

            return(new LocatorResolutionInfo <TClass>(registrationInfo, propRegistrationInfo));
        }
コード例 #2
0
ファイル: TypeMapper.cs プロジェクト: stadub/Net.Utils
        public TypeMapper(ServiceLocator locator)
        {
            DestType = typeof(TDest);

            SourceType          = typeof(TSource);
            propertyMappingInfo = new PropertyMappingInfo <TDest>();
            registrationInfo    = new PropertyRegistrationInfo <TDest>();
            locatorMappingInfo  = new LocatorRegistrationInfo <TDest>();
            this.locator        = locator;
            LocatorInjectOnlyFlaggedProperties = true;
        }