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);
        }