예제 #1
0
        private static TService FindAndCreateConfiguredType <TService>(IEnumerable <TypeMapping> configuredTypeMappings)
            where TService : class
        {
            TypeMapping mapping = FindMappingForType <TService>(configuredTypeMappings);

            if (mapping == null)
            {
                return(null);
            }

            return((TService)ActivatingServiceLocator.CreateInstanceFromTypeMapping(mapping));
        }
        public void LoadTypeMappings(IServiceLocator serviceLocator, IEnumerable <TypeMapping> typeMappings)
        {
            if (typeMappings == null)
            {
                return;
            }

            Validation.ArgumentNotNull(serviceLocator, "serviceLocator");
            Validation.TypeIsAssignable(typeof(ActivatingServiceLocator), serviceLocator.GetType(), "serviceLocator");

            ActivatingServiceLocator activatingServiceLocator = serviceLocator as ActivatingServiceLocator;

            foreach (TypeMapping typeMapping in typeMappings)
            {
                activatingServiceLocator.RegisterTypeMapping(typeMapping);
            }
        }