/// <summary> /// Adds the given <see cref="Microsoft.SharePoint.SPWeb"/> object to the cache. /// If a <see cref="Microsoft.SharePoint.SPWeb"/> with the same site GUID already exists in cache, the given one is ignored. /// </summary> /// <param name="web">Site object.</param> /// <returns>An <see cref="Microsoft.SharePoint.SPWeb"/> object in cache. Returned object is not necessary the same instance as the given one.</returns> /// <exception cref="System.ArgumentNullException">Throws when input parameter <paramref name="web"/> is null.</exception> public SPWeb AddWeb(SPWeb web) { CommonHelper.ConfirmNotNull(web, "web"); SPWebLookupKey lookupKey = new SPWebLookupKey(web); return(GetOrAdd(lookupKey, web)); }
/// <summary> /// Adds the given <see cref="Microsoft.SharePoint.SPWeb"/> object to the cache. /// If a <see cref="Microsoft.SharePoint.SPWeb"/> with the same site GUID already exists in cache, the given one is ignored. /// </summary> /// <param name="web">Site object.</param> /// <returns>An <see cref="Microsoft.SharePoint.SPWeb"/> object in cache. Returned object is not necessary the same instance as the given one.</returns> /// <exception cref="System.ArgumentNullException">Throws when input parameter <paramref name="web"/> is null.</exception> public SPWeb AddWeb(SPWeb web) { CommonHelper.ConfirmNotNull(web, "web"); SPWebLookupKey lookupKey = new SPWebLookupKey(web); hashtable.EnsureKeyValue(web.ServerRelativeUrl, () => new SPListLookupKey(web.ID, Guid.Empty)); return(GetOrAdd(lookupKey, web)); }
/// <summary> /// Gets an <see cref="Microsoft.SharePoint.SPWeb"/> object with the given site GUID. /// </summary> /// <param name="webId">Site GUID.</param> /// <returns>An <see cref="Microsoft.SharePoint.SPWeb"/> object in cache. NULL if site of given GUID does not exist.</returns> public SPWeb GetWeb(Guid webId) { SPWebLookupKey lookupKey = new SPWebLookupKey(webId); SPWeb web = GetOrAdd(lookupKey, () => OpenWeb(webId)); if (web != null) { hashtable.EnsureKeyValue(web.ServerRelativeUrl, () => new SPListLookupKey(web.ID, Guid.Empty)); } return(web); }
/// <summary> /// Gets an <see cref="Microsoft.SharePoint.SPWeb"/> object with the given site GUID. /// </summary> /// <param name="webId">Site GUID.</param> /// <returns>An <see cref="Microsoft.SharePoint.SPWeb"/> object in cache. NULL if site of given GUID does not exist.</returns> public SPWeb GetWeb(Guid webId) { SPWebLookupKey lookupKey = new SPWebLookupKey(webId); return(GetOrAdd(lookupKey, () => contextSite.TryGetWebForCurrentUser(webId))); }