Exemple #1
0
        public List <SPOWeb> GetWebs(bool detailed, bool includeAppWebs)
        {
            if (_detailedSubWebs != null)
            {
                return(_detailedSubWebs);
            }
            if (!detailed && _subWebs != null)
            {
                return(_subWebs);
            }

            var ctx     = SPOSiteContext.CurrentSiteContext.Context;
            var subWebs = _web.Webs;

            ctx.Load(subWebs);
            ctx.ExecuteQuery();
            var webs = new List <SPOWeb>();

            foreach (Web childWeb in subWebs)
            {
                SPOWeb.LoadWeb(ctx, childWeb, detailed);
                webs.Add(new SPOWeb(childWeb));
            }
            _subWebs = webs;
            if (detailed)
            {
                _detailedSubWebs = webs;
            }

            if (includeAppWebs)
            {
                return(webs);
            }
            return(webs.Where(w => w.WebTemplate != "APP").ToList());
        }
        public SPOWeb GetRootWeb(bool detailed)
        {
            if (_rootWebDetailed != null)
            {
                return(_rootWebDetailed);
            }
            if (_rootWeb != null && !detailed)
            {
                return(_rootWeb);
            }

            var ctx     = SPOSiteContext.CurrentSiteContext.Context;
            var rootWeb = this.Site.RootWeb;

            SPOWeb.LoadWeb(ctx, rootWeb, detailed);
            ctx.ExecuteQuery();

            var spoWeb = new SPOWeb(rootWeb);

            if (detailed)
            {
                _rootWebDetailed = spoWeb;
            }
            else
            {
                _rootWeb = spoWeb;
            }

            return(spoWeb);
        }
Exemple #3
0
        private void IterateWebs(Web parentWeb, List <SPOWeb> webs, bool detailed)
        {
            var ctx       = SPOSiteContext.CurrentSiteContext.Context;
            var childWebs = parentWeb.Webs;

            ctx.Load(childWebs);
            ctx.ExecuteQuery();
            foreach (Web childWeb in childWebs)
            {
                SPOWeb.LoadWeb(ctx, childWeb, detailed);
                webs.Add(new SPOWeb(childWeb));
                IterateWebs(childWeb, webs, detailed);
            }
        }