public List <SPOList> GetLists(bool detailed) { if (_detailedLists != null) { return(_detailedLists); } if (_lists != null && !detailed) { return(_lists); } var lists = _web.Lists; var ctx = SPOSiteContext.CurrentSiteContext.Context; ctx.Load(lists); ctx.ExecuteQuery(); var spoLists = new List <SPOList>(); foreach (var list in lists) { SPOList.LoadList(ctx, list, detailed); spoLists.Add(new SPOList(list)); } _lists = spoLists; if (detailed) { _detailedLists = spoLists; } return(spoLists); }
protected override void ProcessRecord() { base.ProcessRecord(); var ctx = base.Context; Web web = ctx.Site.OpenWeb(Web.Read()); if (Identity != null) { SPOList list = Identity.Read(web, Detail); WriteObject(list); return; } var lists = web.Lists; ctx.Load(web); ctx.Load(lists); ctx.ExecuteQuery(); foreach (var list in lists) { if (Identity == null) { SPOList.LoadList(ctx, list, Detail); WriteObject(new SPOList(list)); continue; } } }
protected override void ProcessRecord() { base.ProcessRecord(); var ctx = base.Context; Web web = ctx.Site.OpenWeb(Web.Read()); var listci = new ListCreationInformation { CustomSchemaXml = CustomSchemaXml, Description = Description, Title = Title, Url = Url, DocumentTemplateType = DocumentTemplateType, DataSourceProperties = DataSourceProperties, QuickLaunchOption = QuickLaunchOption, TemplateType = TemplateType, TemplateFeatureId = TemplateFeatureId }; List newList = web.Lists.Add(listci); ctx.ExecuteQuery(); SPOList.LoadList(ctx, newList, true); WriteObject(new SPOList(newList)); }
public SPOList Read(Web web, bool detailed) { var ctx = SPOSiteContext.CurrentSiteContext.Context; List list = null; if (this.ListId != Guid.Empty) { list = web.Lists.GetById(this.ListId); } else if (!string.IsNullOrEmpty(this.ListTitle)) { list = web.Lists.GetByTitle(this.ListTitle); } else if (!string.IsNullOrEmpty(this.Url)) { var lists = web.Lists; ctx.Load(lists, l => l.Include(a => a.Title, a => a.Id, a => a.RootFolder)); ctx.ExecuteQuery(); foreach (var list2 in lists) { string pathAndQuery = HttpUtility.UrlPathEncode(this.Url, true); if (!this.Url.StartsWith("/")) { pathAndQuery = new Uri(this.Url).PathAndQuery; } if (HttpUtility.UrlPathEncode(list2.RootFolder.ServerRelativeUrl, true).ToLower().TrimEnd('/') == pathAndQuery.ToLower().TrimEnd('/')) { list = list2; break; } } } if (list != null) { _list = list; SPOList.LoadList(ctx, list, detailed); return(new SPOList(list)); } return(null); }