private IServiceLocator RefreshServiceLocatorInstance(SPSite site) { var siteserviceLocatorConfig = GetServiceLocatorConfig(site); SiteLocatorEntry entry = siteLocators[site.ID]; //only update if changed since last time we loaded... if (siteserviceLocatorConfig.LastUpdate > entry.LoadTime) { if (entry.locator.GetType() == typeof(ActivatingServiceLocator)) { // get any mappings added programmatically. Assume this behavior is unique to //Activating service locator, so ignore if not activating. var activatingLocator = (ActivatingServiceLocator)entry.locator; activatingLocator.Refresh(GetDefaultTypeMappings(), FarmLocatorConfig.GetTypeMappings(), entry.SiteMappings, siteserviceLocatorConfig.GetTypeMappings()); } else { IServiceLocatorFactory factory = GetServiceLocatorFactory(this.FarmLocatorConfig.GetTypeMappings()); SetupCustomLocator(factory, entry.locator, siteserviceLocatorConfig.GetTypeMappings()); } entry.SiteMappings = siteserviceLocatorConfig.GetTypeMappings(); } entry.LoadTime = DateTime.Now; return(entry.locator); }
private IServiceLocator CreateServiceLocatorInstance() { var configuredTypeMappings = FarmLocatorConfig.GetTypeMappings(); // Create the factory that can configure and create the service locator It's possible that the factory to be used has been changed in config. var serviceLocatorFactory = GetServiceLocatorFactory(configuredTypeMappings); // Create the service locator and load it up with the default and configured type mappings var serviceLocator = serviceLocatorFactory.Create(); serviceLocatorFactory.LoadTypeMappings(serviceLocator, GetDefaultTypeMappings()); serviceLocatorFactory.LoadTypeMappings(serviceLocator, configuredTypeMappings); return(serviceLocator); }
private void SetupCustomLocator(IServiceLocatorFactory factory, IServiceLocator locator, IEnumerable <TypeMapping> siteMappings) { factory.LoadTypeMappings(locator, GetDefaultTypeMappings()); factory.LoadTypeMappings(locator, FarmLocatorConfig.GetTypeMappings()); factory.LoadTypeMappings(locator, siteMappings); }