public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <TaxonomyTermStoreReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var context = typedHost.HostClientContext;
            var site    = typedHost.HostSite;

            var session   = TaxonomySession.GetTaxonomySession(context);
            var termStore = session.GetDefaultSiteCollectionTermStore();

            context.Load(site);
            context.Load(termStore);

            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(new[] { site }, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <TaxonomyTermStoreReverseHost>(parentHost, h =>
                {
                    h.HostTermStore = termStore;
                }));
            }));

            return(result);
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <ListReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <ListReverseHost>("reverseHost", value => value.RequireNotNull());

            var list    = typedHost.HostList;
            var context = typedHost.HostClientContext;

            var folder = list.RootFolder;

            context.Load(list);
            context.Load(list, l => l.ContentTypes);
            context.Load(folder);
            context.Load(folder, f => f.UniqueContentTypeOrder);

            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(new[] { list }, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <ListReverseHost>(parentHost, h =>
                {
                    h.HostList = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<ListViewReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<ListReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var web = typedHost.HostWeb;
            var list = typedHost.HostList;

            var context = typedHost.HostClientContext;

            var items = list.Views;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<ListViewReverseHost>(parentHost, h =>
                {
                    h.HostListView = i;
                });
            }));

            return result;
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <ListReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <WebReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var web  = typedHost.HostWeb;

            var context = typedHost.HostClientContext;

            var items = web.Lists;

            //context.Load(items, i => i.Include(r => r.RootFolder, r => r.RootFolder.Properties));
            context.Load(items,
                         i => i.Include(r => r.RootFolder,
                                        r => r.Title,
                                        r => r.Description,
                                        r => r.Hidden,
                                        r => r.BaseTemplate,
                                        r => r.ContentTypesEnabled)

                         );
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <ListReverseHost>(parentHost, h =>
                {
                    h.HostList = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <SandboxSolutionReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site    = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            var solutionList = site.RootWeb.GetCatalog((int)ListTemplateType.SolutionCatalog);
            var items        = solutionList.RootFolder.Files;

            context.Load(items, i => i.Include(f => f.Name,
                                               f => f.ServerRelativeUrl,
                                               f => f.ListItemAllFields));
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <SandboxSolutionReverseHost>(parentHost, h =>
                {
                    h.HostSandboxSolutionFile = i;
                }));
            }));

            return(result);
        }
示例#6
0
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <ContentTypeReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <ContentTypeReverseHost>("reverseHost", value => value.RequireNotNull());

            var contentType = typedHost.HostContentType;
            var context     = typedHost.HostClientContext;

            var item = contentType;

            context.Load(item);

            context.Load(item, i => i.Fields);
            context.Load(item, i => i.FieldLinks);

            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(new[] { item }, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <ContentTypeReverseHost>(parentHost, h =>
                {
                    h.HostContentType = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <TaxonomyFieldReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site    = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            // TODO

            //var items = site.RootWeb.SiteGroups;

            //context.Load(items);
            //context.ExecuteQuery();

            //result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            //{
            //    return ModelHostBase.Inherit<TaxonomyFieldReverseHost>(parentHost, h =>
            //    {
            //        h.HostGroup = i;
            //    });
            //}));

            return(result);
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<TaxonomyTermStoreReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var context = typedHost.HostClientContext;
            var site = typedHost.HostSite;

            var session = TaxonomySession.GetTaxonomySession(context);
            var termStore = session.GetDefaultSiteCollectionTermStore();

            context.Load(site);
            context.Load(termStore);

            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(new[] { site }, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<TaxonomyTermStoreReverseHost>(parentHost, h =>
                {
                    h.HostTermStore = termStore;
                });
            }));

            return result;
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<SandboxSolutionReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            var solutionList = site.RootWeb.GetCatalog((int)ListTemplateType.SolutionCatalog);
            var items = solutionList.RootFolder.Files;

            context.Load(items, i => i.Include(f => f.Name,
                                               f => f.ServerRelativeUrl,
                                               f => f.ListItemAllFields));
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<SandboxSolutionReverseHost>(parentHost, h =>
                {
                    h.HostSandboxSolutionFile = i;
                });
            }));

            return result;
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<ListReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<WebReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var web = typedHost.HostWeb;

            var context = typedHost.HostClientContext;

            var items = web.Lists;

            //context.Load(items, i => i.Include(r => r.RootFolder, r => r.RootFolder.Properties));
            context.Load(items,
                i => i.Include(r => r.RootFolder,
                                    r => r.Title,
                                    r => r.Description,
                                    r => r.Hidden,
                                    r => r.BaseTemplate,
                                    r => r.ContentTypesEnabled)

                );
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<ListReverseHost>(parentHost, h =>
                {
                    h.HostList = i;
                });
            }));

            return result;
        }
示例#11
0
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <TaxonomyTermSetReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <TaxonomyTermGroupReverseHost>("reverseHost", value => value.RequireNotNull());

            var context = typedHost.HostClientContext;

            var site      = typedHost.HostSite;
            var termGroup = typedHost.HostTermGroup;

            var items = termGroup.TermSets;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <TaxonomyTermSetReverseHost>(parentHost, h =>
                {
                    h.HostTermSet = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<TaxonomyFieldReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            // TODO        

            //var items = site.RootWeb.SiteGroups;

            //context.Load(items);
            //context.ExecuteQuery();

            //result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            //{
            //    return ModelHostBase.Inherit<TaxonomyFieldReverseHost>(parentHost, h =>
            //    {
            //        h.HostGroup = i;
            //    });
            //}));

            return result;
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <WebPartPageReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site    = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            Folder hostFolder = null;

            if (parentHost is FolderReverseHost)
            {
                hostFolder = (parentHost as FolderReverseHost).HostFolder;
            }
            else if (parentHost is ListReverseHost)
            {
                hostFolder = (parentHost as ListReverseHost).HostList.RootFolder;
            }
            else
            {
                throw new SPMeta2ReverseException(
                          string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            // TODO, query only web part pages
            var items = hostFolder.Files;

            context.Load(items, i => i.Include(
                             t => t.ListItemAllFields,
                             t => t.Name,
                             t => t.ServerRelativeUrl,
                             t => t.Title));
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <WebPartPageReverseHost>(parentHost, h =>
                {
                    h.HostWebPartPageFile = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<WebPartPageReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            Folder hostFolder = null;

            if (parentHost is FolderReverseHost)
                hostFolder = (parentHost as FolderReverseHost).HostFolder;
            else if (parentHost is ListReverseHost)
                hostFolder = (parentHost as ListReverseHost).HostList.RootFolder;
            else
            {
                throw new SPMeta2ReverseException(
                    string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            // TODO, query only web part pages
            var items = hostFolder.Files;

            context.Load(items, i => i.Include(
                                            t => t.ListItemAllFields,
                                            t => t.Name,
                                            t => t.ServerRelativeUrl,
                                            t => t.Title));
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<WebPartPageReverseHost>(parentHost, h =>
                {
                    h.HostWebPartPageFile = i;
                });
            }));

            return result;
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <ModuleFileReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site    = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            Folder hostFolder = null;

            if (parentHost is FolderReverseHost)
            {
                hostFolder = (parentHost as FolderReverseHost).HostFolder;
            }
            else if (parentHost is ListReverseHost)
            {
                hostFolder = (parentHost as ListReverseHost).HostList.RootFolder;
            }
            else
            {
                throw new SPMeta2ReverseException(
                          string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            var items = hostFolder.Files;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <ModuleFileReverseHost>(parentHost, h =>
                {
                    h.HostFolder = hostFolder;
                    h.HostFile = i;
                }));
            }));

            return(result);
        }
示例#16
0
        public override IEnumerable <ReverseHostBase> ReverseHosts(
            ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <TaxonomyTermSetReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <TaxonomyTermGroupReverseHost>("reverseHost", value => value.RequireNotNull());

            var context = typedHost.HostClientContext;

            var site = typedHost.HostSite;

            TermCollection items = null;

            if (parentHost is TaxonomyTermReverseHost)
            {
                items = (parentHost as TaxonomyTermReverseHost).HostTerm.Terms;
            }
            else if (parentHost is TaxonomyTermSetReverseHost)
            {
                items = (parentHost as TaxonomyTermSetReverseHost).HostTermSet.Terms;
            }
            else
            {
                throw new SPMeta2ReverseException(
                          string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <TaxonomyTermReverseHost>(parentHost, h =>
                {
                    h.HostTerm = i;
                }));
            }));

            return(result);
        }
示例#17
0
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <NavigationNodeReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <WebReverseHost>("reverseHost", value => value.RequireNotNull());
            var context   = typedHost.HostClientContext;

            var items = GetNavigationNodes(parentHost, options);

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return(ModelHostBase.Inherit <NavigationNodeReverseHost>(parentHost, h =>
                {
                    h.HostNavigationNode = i;
                }));
            }));

            return(result);
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<ModuleFileReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            Folder hostFolder = null;

            if (parentHost is FolderReverseHost)
                hostFolder = (parentHost as FolderReverseHost).HostFolder;
            else if (parentHost is ListReverseHost)
                hostFolder = (parentHost as ListReverseHost).HostList.RootFolder;
            else
            {
                throw new SPMeta2ReverseException(
                    string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            var items = hostFolder.Files;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<ModuleFileReverseHost>(parentHost, h =>
                {
                    h.HostFolder = hostFolder;
                    h.HostFile = i;
                });
            }));

            return result;
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(
            ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<TaxonomyTermSetReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<TaxonomyTermGroupReverseHost>("reverseHost", value => value.RequireNotNull());

            var context = typedHost.HostClientContext;

            var site = typedHost.HostSite;

            TermCollection items = null;

            if (parentHost is TaxonomyTermReverseHost)
                items = (parentHost as TaxonomyTermReverseHost).HostTerm.Terms;
            else if (parentHost is TaxonomyTermSetReverseHost)
                items = (parentHost as TaxonomyTermSetReverseHost).HostTermSet.Terms;
            else
            {
                throw new SPMeta2ReverseException(
                    string.Format("Unsupported host:[{0}]", parentHost.GetType()));
            }

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i =>
            {
                return ModelHostBase.Inherit<TaxonomyTermReverseHost>(parentHost, h =>
                {
                    h.HostTerm = i;
                });
            }));

            return result;
        }
        public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List<ContentTypeReverseHost>();

            var typedHost = parentHost.WithAssertAndCast<SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            var items = site.RootWeb.ContentTypes;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(items.ToArray().Where(i => ShouldReverse(i)).Select(i =>
            {
                return ModelHostBase.Inherit<ContentTypeReverseHost>(parentHost, h =>
                {
                    h.HostContentType = i;
                });
            }));

            return result;
        }
        public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options)
        {
            var result = new List <ContentTypeReverseHost>();

            var typedHost = parentHost.WithAssertAndCast <SiteReverseHost>("reverseHost", value => value.RequireNotNull());

            var site    = typedHost.HostSite;
            var context = typedHost.HostClientContext;

            var items = site.RootWeb.ContentTypes;

            context.Load(items);
            context.ExecuteQueryWithTrace();

            result.AddRange(ApplyReverseFilters(items.ToArray().Where(i => ShouldReverse(i)), options).Select(i =>
            {
                return(ModelHostBase.Inherit <ContentTypeReverseHost>(parentHost, h =>
                {
                    h.HostContentType = i;
                }));
            }));

            return(result);
        }
        protected override NavigationNodeCollection GetNavigationNodes(ReverseHostBase parentHost, ReverseOptions options)
        {
            var typedHost = parentHost.WithAssertAndCast<WebReverseHost>("reverseHost", value => value.RequireNotNull());

            return typedHost.HostWeb.Navigation.QuickLaunch;
        }
        protected override NavigationNodeCollection GetNavigationNodes(ReverseHostBase parentHost, ReverseOptions options)
        {
            var typedHost = parentHost.WithAssertAndCast <WebReverseHost>("reverseHost", value => value.RequireNotNull());

            return(typedHost.HostWeb.Navigation.TopNavigationBar);
        }