public static void AddMonitor(SPChangeMonitor monitor) { CommonHelper.ConfirmNotNull(monitor, "monitor"); SPChangeQueryExecutor instance = factory.GetInstance(monitor.SiteId, () => new SPChangeQueryExecutor(monitor.SiteId)); instance.monitors.Add(monitor); }
public static SPModelParameterizedQuery Create(Expression expression, ISPModelManagerInternal manager) { CommonHelper.ConfirmNotNull(expression, "expression"); CommonHelper.ConfirmNotNull(manager, "manager"); object[] args; ParameterizedExpression pq = ParameterizedExpression.Create(expression, out args); SPModelParameterizedQuery cached = cache.GetInstance(pq, p => new SPModelParameterizedQuery(pq, manager)); return(cached.BindParameters(args, manager)); }
/// <summary> /// Returns the MIME mapping for the specified file name. /// </summary> /// <param name="filename">The file name that is used to determine the MIME type.</param> /// <returns></returns> public static string GetMimeMapping(string filename) { CommonHelper.ConfirmNotNull(filename, "filename"); if (HostingEnvironment.IsHosted) { string siteName = HostingEnvironment.ApplicationHost.GetSiteName(); Hashtable ht = cache.GetInstance(siteName, LoadMimeMappings); string value = (string)ht[Path.GetExtension(filename)]; if (value != null) { return(value); } } object entry = Registry.GetValue("HKEY_CLASSES_ROOT\\" + Path.GetExtension(filename), "Content Type", null); if (entry != null) { return(entry.ToString()); } return("application/octet-stream"); }
/// <summary> /// Gets an instance of the current type <typeparamref name="T"/> which loads configuration from the specified site collection, /// and optionally refresh the cache. /// </summary> /// <param name="siteId">The GUID of a site collection.</param> /// <param name="forceRefresh">Whether to refresh the cache.</param> /// <returns>An instance of the current type <typeparamref name="T"/> which loads configuration from the given site collection.</returns> public static T Load(Guid siteId, bool forceRefresh) { if (forceRefresh) { InstanceFactory.Destroy(siteId); } try { // avoid config being cache without adding cache policy to HttpContext.Current.Cache if (HttpContext.Current == null) { T config; if (((IDictionary <Guid, T>)InstanceFactory).TryGetValue(siteId, out config)) { return(config); } return(LoadInternal(siteId)); } return(InstanceFactory.GetInstance(siteId, LoadInternal)); } catch (Exception ex) { Logger.Error(ex); return(new T()); } }
/// <summary> /// Gets a mapping of SharePoint field names to managed property names. /// </summary> /// <param name="searchApplication">A search service application.</param> /// <returns>A mapping of SharePoint field names to managed property names.</returns> public static IReadOnlyDictionary <string, string> GetManagedPropertyNames(SearchServiceApplication searchApplication) { CommonHelper.ConfirmNotNull(searchApplication, "searchApplication"); return(SearchApplicationIdFactory.GetInstance(searchApplication.Id, () => GetManagedPropertyNamesUncached(searchApplication).AsReadOnly())); }
/// <summary> /// Gets a mapping of SharePoint field names to managed property names. /// </summary> /// <param name="site">A site collection object.</param> /// <returns>A mapping of SharePoint field names to managed property names.</returns> public static IReadOnlyDictionary <string, string> GetManagedPropertyNames(SPSite site) { CommonHelper.ConfirmNotNull(site, "site"); return(SPSiteIdFactory.GetInstance(site.ID, () => GetManagedPropertyNamesUncached(site).AsReadOnly())); }