Esempio n. 1
0
 private void OnFarmTypeMappingChanged(object sender, TypeMappingChangedArgs args)
 {
     lock (syncRoot)
     {
         foreach (SiteLocatorEntry entry in siteLocators.Values)
         {
             //only override if not defined at the site level.
             if (entry.SiteMappings == null ||
                 entry.SiteMappings.Exists((t) => t.Key == args.Mapping.Key &&
                                           t.FromAssembly == args.Mapping.FromAssembly &&
                                           t.FromType == args.Mapping.FromType) == false)
             {
                 var activatingLocator = entry.locator as ActivatingServiceLocator;
                 if (activatingLocator != null)
                 {
                     activatingLocator.RegisterTypeMapping(args.Mapping);
                 }
             }
         }
     }
 }
        public ActivatingServiceLocator RegisterTypeMapping(TypeMapping mapping)
        {
            TypeMapping.ValidateMapping(mapping);

            if (!this.typeMappingsDictionary.ContainsKey(mapping.FromType))
            {
                this.typeMappingsDictionary[mapping.FromType] = new Dictionary <string, TypeMapping>();
            }

            Dictionary <string, TypeMapping> mappingsForType = this.typeMappingsDictionary[mapping.FromType];

            mappingsForType[mapping.GetNonNullKey()] = mapping;

            EventHandler <TypeMappingChangedArgs> handler = this.MappingRegisteredEvent;

            if (handler != null)
            {
                TypeMappingChangedArgs args = new TypeMappingChangedArgs();
                args.Mapping = mapping;
                handler(this, args);
            }

            return(this);
        }