Esempio n. 1
0
        /// <summary>
        /// Load a term group from current <see cref="TaxonomyOperation.LastTermStore"/> by given <paramref name="guid"/> parameter.
        /// <para>This method does not add loaded term group in <see cref="TaxonomyOperation.LoadedTermGroups"/>.
        /// See Remarks section!</para>
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="guid">Id of the term group</param>
        /// <remarks>This method does not add loaded group into <see cref="TaxonomyOperation.LoadedTermGroups"/> because the name is not available yet</remarks>
        /// <returns></returns>
        public static CSOMOperation LoadTermGroup(this CSOMOperation operation, Guid guid, params Expression <Func <TermGroup, object> >[] retrievals)
        {
            var op = operation.TaxonomyOperation;

            op.LastTermGroup = op.LastTermStore.Groups.GetById(guid);
            operation.Load(op.LastTermGroup, retrievals.Length == 0 ? DefaultRetrievals.TermGroup : retrievals);

            return(operation);
        }
Esempio n. 2
0
        public static CSOMOperation GetWebTemplates(this CSOMOperation operation, uint?lcid = null, int?compatibilityLevel = null)
        {
            lcid = lcid ?? operation.DefaultLcid;
            compatibilityLevel = compatibilityLevel ?? operation.DefaultCompatibilityLevel;

            var templates = operation.LastSite.GetWebTemplates(lcid.Value, compatibilityLevel.Value);

            operation.Load(templates, CSOMOperation.DefaultRetrievals.WebTemplateCollection);
            return(operation);
        }
Esempio n. 3
0
        /// <summary>
        /// Get Item using CamlQuery
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="query"></param>
        /// <param name="retrievals"></param>
        /// <returns></returns>
        public static ListItem GetItem(this CSOMOperation operation, CamlQuery query)
        {
            ListItemCollection items = operation
                                       .LastList
                                       .GetItems(query);

            ListItem item = items.FirstOrDefault();

            operation.Load(item);

            return(item);
        }
Esempio n. 4
0
        /// <summary>
        /// Get Item by id
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="itemId"></param>
        /// <param name="retrievals"></param>
        /// <returns></returns>
        public static ListItem GetItem(this CSOMOperation operation, int itemId, params Expression <Func <ListItem, object> >[] retrievals)
        {
            ListItem item = operation.LastList.GetItemById(itemId);

            operation
            .Load(item, retrievals.Length > 0
                                                                                ? retrievals
                                                                                : CSOMOperation.DefaultRetrievals.ListItem)
            .Execute();

            return(item);
        }
Esempio n. 5
0
        /// <summary>
        /// Load a term group from current <see cref="TaxonomyOperation.LastTermStore"/> by given <paramref name="name"/> parameter.
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="name">Name of the term group</param>
        /// <param name="retrievals">When not retrievals are supplied <see cref="DefaultRetrievals.TermGroup"/> are used.</param>
        /// <returns></returns>
        public static CSOMOperation LoadTermGroup(this CSOMOperation operation, string name, params Expression <Func <TermGroup, object> >[] retrievals)
        {
            var op = operation.TaxonomyOperation;

            op.LastTermGroup = op.LastTermStore.Groups.GetByName(name);
            operation.Load(op.LastTermGroup, retrievals.Length == 0 ? DefaultRetrievals.TermGroup : retrievals);

            if (op.LoadedTermGroups.ContainsKey(name.ToLower()))
            {
                op.LoadedTermGroups[name.ToLower()] = op.LastTermGroup;
            }
            else
            {
                op.LoadedTermGroups.Add(name.ToLower(), op.LastTermGroup);
            }

            return(operation);
        }
Esempio n. 6
0
        public static CSOMOperation LoadTerm(this CSOMOperation operation, string name, params Expression <Func <TermSet, object> >[] retrievals)
        {
            var op  = operation.TaxonomyOperation;
            var key = name.ToLower();

            op.LastTerm = op.LastTermSet.Terms.GetByName(name);
            operation.Load(op.LastTermSet, retrievals.Length == 0 ? DefaultRetrievals.TermSet : retrievals);

            if (op.LoadedTermSets.ContainsKey(key))
            {
                op.LoadedTermSets[key] = op.LastTermSet;
            }
            else
            {
                op.LoadedTermSets.Add(key, op.LastTermSet);
            }

            return(operation);
        }