예제 #1
0
        private SPWeb OpenWeb(Guid webId)
        {
            SPWeb web = SPExtensionHelper.OpenWebSafe(contextSite, webId);

            disposables.Add(web);
            return(web);
        }
예제 #2
0
        /// <summary>
        /// Gets an <see cref="Microsoft.SharePoint.SPWeb"/> object with the given URL.
        /// </summary>
        /// <param name="webUrl">Site URL.</param>
        /// <returns>An <see cref="Microsoft.SharePoint.SPWeb"/> object in cache. NULL if site of given URL does not exist.</returns>
        public SPWeb TryGetWeb(string webUrl)
        {
            CommonHelper.ConfirmNotNull(webUrl, "webUrl");
            SPListLookupKey lookupKey = hashtable[webUrl] as SPListLookupKey;

            if (lookupKey != null)
            {
                return(GetWeb(lookupKey.WebId));
            }
            SPWeb web = SPExtensionHelper.OpenWebSafe(contextSite, webUrl, false);

            if (web != null)
            {
                SPWeb returnValue = AddWeb(web);
                if (returnValue != web)
                {
                    web.Dispose();
                }
                return(returnValue);
            }
            return(null);
        }