Exemplo n.º 1
0
        private static TService FindAndCreateConfiguredType <TService>(IEnumerable <TypeMapping> configuredTypeMappings)
            where TService : class
        {
            var mapping = FindMappingForType <TService>(configuredTypeMappings);

            if (mapping == null)
            {
                return(null);
            }
            return((TService)ActivatingServiceLocator.CreateInstanceFromTypeMapping(mapping, null));
        }
Exemplo n.º 2
0
        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);
            }
        }