private SPWeb OpenWeb(Guid webId)
        {
            SPWeb web = SPExtensionHelper.OpenWebSafe(contextSite, webId);

            disposables.Add(web);
            return(web);
        }
 private ICollection <int> GetDeletedTermIDs()
 {
     if (deletedTerms == null)
     {
         deletedTerms = new List <int>();
         SPList    taxonomyHiddenList = SPExtensionHelper.GetTaxonomyHiddenList(manager.Site);
         TermStore termStore          = manager.TermStore;
         SPQuery   query = new SPQuery {
             Query      = Caml.Equals("IdForTermStore", termStore.Id.ToString()).ToString(),
             ViewFields = Caml.ViewFields("IdForTerm").ToString()
         };
         foreach (SPListItem item in taxonomyHiddenList.GetItems(query))
         {
             if (termStore.GetTerm(new Guid((string)item["IdForTerm"])) == null)
             {
                 deletedTerms.Add(item.ID);
             }
         }
     }
     return(deletedTerms);
 }
        private CamlExpression HandleNullExpression(SPModelQueryFieldInfo field, bool negate)
        {
            CamlExpression expression = Caml.IsNull(field.FieldRef);

            if (field.FieldTypeAsString == "TaxonomyFieldType" || field.FieldTypeAsString == "TaxonomyFieldTypeMulti")
            {
                SPList taxonomyHiddenList = SPExtensionHelper.GetTaxonomyHiddenList(manager.Site);
                foreach (SPListItem item in taxonomyHiddenList.GetItems("IdForTerm"))
                {
                    if (manager.TermStore.GetTerm(new Guid((string)item["IdForTerm"])) == null)
                    {
                        expression |= Caml.LookupIdEquals(field.FieldRef, item.ID);
                    }
                }
            }
            if (negate)
            {
                return(~expression);
            }
            return(expression);
        }
        /// <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);
        }