Example #1
0
        public static CSOMOperation CreateWeb(this CSOMOperation operation, string title, int?lcid, string url = "", string template = "")
        {
            operation.LogInfo($"Creating web {title}");

            url = url.IsNotNullOrEmpty() ? url : operation.NormalizeUrl(title);
            Web rootWeb = operation.DecideWeb();

            lcid = (int)((uint?)lcid ?? operation.DecideWeb().Language);

            operation.LogDebug($"Web creation information set to Title: {title}, Url: {url}, Lcid: {lcid}, Template: {template}");
            WebCreationInformation webInformation = new WebCreationInformation
            {
                Title       = title,
                Url         = url,
                WebTemplate = template,
                Language    = lcid.Value
            };

            var web = rootWeb.Webs.Add(webInformation);

            operation.LoadWebWithDefaultRetrievals(web);

            operation.SetLevel(OperationLevels.Web, web);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = web, Action = DeferredActions.Load
            });

            return(operation);
        }
Example #2
0
        public static CSOMOperation LoadList(this CSOMOperation operation, string name, Action <ClientContext, Microsoft.SharePoint.Client.List> listLoader = null)
        {
            operation.LogDebug($"Loading list {name}");

            var web  = operation.DecideWeb();
            var list = web.Lists.GetByTitle(name);

            operation.LoadListRequired(list);

            if (listLoader != null)
            {
                listLoader(operation.Context, list);
            }
            else
            {
                operation.Context.Load(list);
            }

            operation.SetLevel(OperationLevels.List, list);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = operation.LastList, Action = DeferredActions.Load
            });

            return(operation);
        }
Example #3
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 #4
0
        public static CSOMOperation LoadWebs(this CSOMOperation operation, params Expression <Func <Microsoft.SharePoint.Client.Web, object> >[] keysToLoad)      // todo add custom loader
        {
            operation.LogDebug("Loading all webs");

            var webs = operation.DecideWeb().Webs;

            operation.Context.Load(webs, CSOMOperation.DefaultRetrievals.WebCollection);

            if (keysToLoad.Length > 0)
            {
                operation.Context.Load(webs, w => w.Include(keysToLoad));
            }

            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = webs, Action = DeferredActions.Load
            });

            return(operation);
        }