Beispiel #1
0
        public SPListInfo[] GetLists()
        {
            List<SPListInfo> ret = new List<SPListInfo>();

             using (ClientContext clientContext = CreateContext())
             {
            clientContext.Load(clientContext.Web.Lists);
            clientContext.Load(clientContext.Web.Lists, lists => lists.Include(l => l.RootFolder.ServerRelativeUrl, l => l.OnQuickLaunch));
            clientContext.ExecuteQuery();

            SPTemplateType baseTemplateType = SPTemplateType.All;
            Uri siteUri = new Uri(_serverSettings.Uri);

            if (clientContext.Web.Lists.Count > 0)
            {
               foreach (List list in clientContext.Web.Lists)
               {
                  if (EnsureValidListTemplate(list, baseTemplateType))
                  {
                     SPListInfo spListInfo = new SPListInfo(siteUri, list);
                     ret.Add(spListInfo);
                  }
               }
            }
             }

             return ret.ToArray();
        }
Beispiel #2
0
 public SPListInfo(Uri siteUri, List list)
 {
     Id = list.Id;
      Title = list.Title;
      ServerRelativeUrl = list.RootFolder.ServerRelativeUrl;
      AbsoluteUri = SPHelper.CombineUrl(siteUri, ServerRelativeUrl);
      BaseTemplate = (SPTemplateType)list.BaseTemplate;
      Created = list.Created;
      Description = list.Description;
 }
Beispiel #3
0
        private bool EnsureValidListTemplate(List list, SPTemplateType baseTemplateType)
        {
            BaseType listBaseType = (BaseType)list.BaseType;
             if (list.Hidden || listBaseType != BaseType.DocumentLibrary)
             {
            return false;
             }

             SPTemplateType listBaseTemplate = (SPTemplateType)list.BaseTemplate;

             if (baseTemplateType == SPTemplateType.All)
             {
            return listBaseTemplate == SPTemplateType.DocumentLibrary ||
                   listBaseTemplate == SPTemplateType.PictureLibrary ||
                   listBaseTemplate == SPTemplateType.AssetLibrary;
             }
             else
             {
            return listBaseTemplate == baseTemplateType;
             }
        }