示例#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));
        }
示例#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);
            }
        }