Example #1
0
        public static ListTemplateCollection GetListTemplates(this CSOMOperation operation, params Expression <Func <ListTemplateCollection, object> >[] retrievals)
        {
            var templates = operation.LastSite.GetCustomListTemplates(operation.DecideWeb());

            operation.Context.Load(templates, retrievals.Length > 0
                                        ? retrievals
                                        : CSOMOperation.DefaultRetrievals.ListTemplateCollection);

            operation.Execute();

            return(templates);
        }
Example #2
0
        public static TermCollection GetAllTerms(this CSOMOperation operation, string termSetName, uint lcid, params Expression <Func <Term, object> >[] keysToLoad)
        {
            var termSets = TaxonomySession.GetTaxonomySession(operation.Context).GetTermSetsByName(termSetName, (int)lcid);

            operation.Context.Load(termSets);
            operation.Execute();

            if (termSets.Count == 0)
            {
                throw new KeyNotFoundException($"Term set {termSetName} not found");
            }

            var terms = termSets.First().GetAllTerms();

            operation.Context.Load(terms, t => t.Include(keysToLoad));
            operation.Context.ExecuteQuery();

            return(terms);
        }
Example #3
0
        public static WebTemplateCollection GetWebTemplates(this CSOMOperation operation, uint lcid, bool overrideCompatibilityLevel = false, Action <ClientContext, WebTemplateCollection> templatesLoader = null)
        {
            operation.LogInfo($"Getting web templates for LCID {lcid}");

            var collection = operation.LastSite.GetWebTemplates(lcid, overrideCompatibilityLevel ? 1 : 0);

            if (templatesLoader != null)
            {
                templatesLoader(operation.Context, collection);
            }
            else
            {
                operation.Context.Load(collection);
            }

            operation.Execute();

            return(collection);
        }
Example #4
0
        /// <summary>
        /// Get items from the last loaded list using standard <see cref="CamlQuery"/>
        /// </summary>
        /// <param name="operation">Beware! Context executing method</param>
        /// <param name="query">Query used in GetItems method</param>
        /// <param name="retrievals"></param>
        /// <returns>Loaded list items in standard CSOM <see cref="ListItemCollection"/></returns>
        public static ListItemCollection GetItems(this CSOMOperation operation, CamlQuery query, params Expression <Func <ListItem, object> >[] retrievals)
        {
            operation.LogInfo("Getting items");
            operation.LogDebug($"Query:\n{query.ViewXml}");

            var listItems = operation.LastList.GetItems(query);

            if (retrievals != null)
            {
                operation.Context.Load(listItems, collection => collection.Include(retrievals));
            }
            else
            {
                operation.Context.Load(listItems);
            }

            operation.Execute();

            return(listItems);
        }