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 <PropertyReverseHost>(); PropertyValues items = null; if (parentHost is ListReverseHost) { items = (parentHost as ListReverseHost).HostList.RootFolder.Properties; } else if (parentHost is WebReverseHost) { items = (parentHost as WebReverseHost).HostWeb.AllProperties; } else if (parentHost is SiteReverseHost) { items = (parentHost as SiteReverseHost).HostSite.RootWeb.AllProperties; } var context = (parentHost as CSOMReverseHostBase).HostClientContext; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items.FieldValues.Keys, options).ToArray().Select(i => { return(ModelHostBase.Inherit <PropertyReverseHost>(parentHost, h => { h.HostPropertyName = i; h.HostPropertyValue = items[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; 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<WelcomePageReverseHost>(); Folder hostFolder = null; if (parentHost is FolderReverseHost) hostFolder = (parentHost as FolderReverseHost).HostFolder; else if (parentHost is ListReverseHost) hostFolder = (parentHost as ListReverseHost).HostList.RootFolder; else if (parentHost is WebReverseHost) hostFolder = (parentHost as WebReverseHost).HostWeb.RootFolder; var context = (parentHost as CSOMReverseHostBase).HostClientContext; context.Load(hostFolder); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(new[] { hostFolder }, options).ToArray().Select(i => { return ModelHostBase.Inherit<WelcomePageReverseHost>(parentHost, h => { h.HostFolder = 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<PropertyReverseHost>(); PropertyValues items = null; if (parentHost is ListReverseHost) items = (parentHost as ListReverseHost).HostList.RootFolder.Properties; else if (parentHost is WebReverseHost) items = (parentHost as WebReverseHost).HostWeb.AllProperties; else if (parentHost is SiteReverseHost) items = (parentHost as SiteReverseHost).HostSite.RootWeb.AllProperties; var context = (parentHost as CSOMReverseHostBase).HostClientContext; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items.FieldValues.Keys, options).ToArray().Select(i => { return ModelHostBase.Inherit<PropertyReverseHost>(parentHost, h => { h.HostPropertyName = i; h.HostPropertyValue = items[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<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 <WelcomePageReverseHost>(); Folder hostFolder = null; if (parentHost is FolderReverseHost) { hostFolder = (parentHost as FolderReverseHost).HostFolder; } else if (parentHost is ListReverseHost) { hostFolder = (parentHost as ListReverseHost).HostList.RootFolder; } else if (parentHost is WebReverseHost) { hostFolder = (parentHost as WebReverseHost).HostWeb.RootFolder; } var context = (parentHost as CSOMReverseHostBase).HostClientContext; context.Load(hostFolder); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(new[] { hostFolder }, options).ToArray().Select(i => { return(ModelHostBase.Inherit <WelcomePageReverseHost>(parentHost, h => { h.HostFolder = 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); }
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 <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<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 <FieldReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var site = siteHost.HostSite; var context = siteHost.HostClientContext; FieldCollection items = null; if (webHost != null) { items = webHost.HostWeb.Fields; } else { items = siteHost.HostSite.RootWeb.Fields; } var typedItems = GetTypedFields(context, items); result.AddRange(ApplyReverseFilters(typedItems, options).ToArray().Select(i => { return(ModelHostBase.Inherit <FieldReverseHost>(parentHost, h => { h.Field = i; })); })); return(result); }
public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { var result = new List<FieldReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var site = siteHost.HostSite; var context = siteHost.HostClientContext; FieldCollection items = null; if (webHost != null) { items = webHost.HostWeb.Fields; } else { items = siteHost.HostSite.RootWeb.Fields; } var typedItems = GetTypedFields(context, items); result.AddRange(ApplyReverseFilters(typedItems, options).ToArray().Select(i => { return ModelHostBase.Inherit<FieldReverseHost>(parentHost, h => { h.Field = 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; }
public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { TraceService.Information((int)ReverseLogEventId.ReverseHostsStart, "Processing web reverse host start"); var result = new List <WebReverseHost>(); Web web = null; if (parentHost is WebReverseHost) { web = (parentHost as WebReverseHost).HostWeb; } else if (parentHost is SiteReverseHost) { web = (parentHost as SiteReverseHost).HostWeb; } var rootWeb = (parentHost as SiteReverseHost).HostSite.RootWeb; var context = (parentHost as CSOMReverseHostBase).HostClientContext; //if (!web.IsObjectPropertyInstantiated("ServerRelativeUrl")) //{ // context.Load(web, w => w.ServerRelativeUrl); // context.Load(rootWeb, w => w.ServerRelativeUrl); // context.ExecuteQueryWithTrace(); //} //var isRootWeb = web.ServerRelativeUrl == rootWeb.ServerRelativeUrl; //if (UseRootWebOnly && isRootWeb) //{ // return new[] { parentHost }; //} var items = web.Webs; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return(ModelHostBase.Inherit <WebReverseHost>(parentHost, h => { h.HostWeb = i; })); })); TraceService.Information((int)ReverseLogEventId.ReverseHostsStart, "Processing web reverse host end"); return(result); }
public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { TraceService.Information((int)ReverseLogEventId.ReverseHostsStart, "Processing web reverse host start"); var result = new List<WebReverseHost>(); Web web = null; if (parentHost is WebReverseHost) web = (parentHost as WebReverseHost).HostWeb; else if (parentHost is SiteReverseHost) web = (parentHost as SiteReverseHost).HostWeb; var rootWeb = (parentHost as SiteReverseHost).HostSite.RootWeb; var context = (parentHost as CSOMReverseHostBase).HostClientContext; //if (!web.IsObjectPropertyInstantiated("ServerRelativeUrl")) //{ // context.Load(web, w => w.ServerRelativeUrl); // context.Load(rootWeb, w => w.ServerRelativeUrl); // context.ExecuteQueryWithTrace(); //} //var isRootWeb = web.ServerRelativeUrl == rootWeb.ServerRelativeUrl; //if (UseRootWebOnly && isRootWeb) //{ // return new[] { parentHost }; //} var items = web.Webs; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return ModelHostBase.Inherit<WebReverseHost>(parentHost, h => { h.HostWeb = i; }); })); TraceService.Information((int)ReverseLogEventId.ReverseHostsStart, "Processing web reverse host end"); 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); }
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 <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 <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<UserCustomActionReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var site = siteHost.HostSite; var web = siteHost.HostWeb; UserCustomActionCollection items = null; if (webHost != null) { web = webHost.HostWeb; items = web.UserCustomActions; } else if(siteHost != null) { items = site.UserCustomActions; } var context = siteHost.HostClientContext; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return ModelHostBase.Inherit<UserCustomActionReverseHost>(parentHost, h => { h.HostUserCustomAction = 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 <UserCustomActionReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var site = siteHost.HostSite; var web = siteHost.HostWeb; UserCustomActionCollection items = null; if (webHost != null) { web = webHost.HostWeb; items = web.UserCustomActions; } else if (siteHost != null) { items = site.UserCustomActions; } var context = siteHost.HostClientContext; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return(ModelHostBase.Inherit <UserCustomActionReverseHost>(parentHost, h => { h.HostUserCustomAction = 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(ApplyReverseFilters(items.ToArray().Where(i => ShouldReverse(i)), options).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 <FolderReverseHost>(); var context = (parentHost as ListReverseHost).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("parentHost should be either FolderReverseHost or ListReverseHost")); } var items = hostFolder.Folders; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return(ModelHostBase.Inherit <FolderReverseHost>(parentHost, h => { h.HostFolder = 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<FolderReverseHost>(); var context = (parentHost as ListReverseHost).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("parentHost should be either FolderReverseHost or ListReverseHost")); } var items = hostFolder.Folders; context.Load(items); context.ExecuteQueryWithTrace(); result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return ModelHostBase.Inherit<FolderReverseHost>(parentHost, h => { h.HostFolder = i; }); })); return result; }
protected abstract NavigationNodeCollection GetNavigationNodes(ReverseHostBase parentHost, ReverseOptions options);
public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { var result = new List<FeatureReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var context = siteHost.HostClientContext; FeatureCollection items = null; var isSiteLevel = false; var isWebLevel = false; var knownFeatures = GetKnownSiteFeatures(); var allKnownFeatures = new List<FeatureDefinition>(); allKnownFeatures.AddRange(GetKnownSiteFeatures()); allKnownFeatures.AddRange(GetKnownWebFeatures()); if (webHost != null) { items = webHost.HostWeb.Features; isWebLevel = true; isSiteLevel = false; knownFeatures = GetKnownWebFeatures(); } else if (siteHost != null) { items = siteHost.HostSite.Features; isWebLevel = false; isSiteLevel = true; knownFeatures = GetKnownSiteFeatures(); } context.Load(items); context.ExecuteQueryWithTrace(); // feature collection will have only activate features // we need to add up OOTB, known features to mark deactivated features // activated features, from the collection result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return ModelHostBase.Inherit<FeatureReverseHost>(parentHost, h => { h.Feature = i; h.IsActivated = true; h.IsSiteLevel = isSiteLevel; h.IsWebLevel = isWebLevel; h.AllKnownFeatures = allKnownFeatures; }); })); // disabled features var activatedFeatureIds = items.ToArray().Select(f => f.DefinitionId); var disabledFeatures = knownFeatures.Where(d => !activatedFeatureIds.Contains(d.Id)); result.AddRange(disabledFeatures.ToArray().Select(i => { return ModelHostBase.Inherit<FeatureReverseHost>(parentHost, h => { h.Feature = null; h.FeatureId = i.Id; h.IsActivated = false; h.IsSiteLevel = isSiteLevel; h.IsWebLevel = isWebLevel; h.AllKnownFeatures = allKnownFeatures; }); })); return result; }
public override IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { return new[] { parentHost }; }
public abstract IEnumerable<ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options);
public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { var result = new List <FeatureReverseHost>(); var siteHost = parentHost as SiteReverseHost; var webHost = parentHost as WebReverseHost; var context = siteHost.HostClientContext; FeatureCollection items = null; var isSiteLevel = false; var isWebLevel = false; var knownFeatures = GetKnownSiteFeatures(); var allKnownFeatures = new List <FeatureDefinition>(); allKnownFeatures.AddRange(GetKnownSiteFeatures()); allKnownFeatures.AddRange(GetKnownWebFeatures()); if (webHost != null) { items = webHost.HostWeb.Features; isWebLevel = true; isSiteLevel = false; knownFeatures = GetKnownWebFeatures(); } else if (siteHost != null) { items = siteHost.HostSite.Features; isWebLevel = false; isSiteLevel = true; knownFeatures = GetKnownSiteFeatures(); } context.Load(items); context.ExecuteQueryWithTrace(); // feature collection will have only activate features // we need to add up OOTB, known features to mark deactivated features // activated features, from the collection result.AddRange(ApplyReverseFilters(items, options).ToArray().Select(i => { return(ModelHostBase.Inherit <FeatureReverseHost>(parentHost, h => { h.Feature = i; h.IsActivated = true; h.IsSiteLevel = isSiteLevel; h.IsWebLevel = isWebLevel; h.AllKnownFeatures = allKnownFeatures; })); })); // disabled features var activatedFeatureIds = items.ToArray().Select(f => f.DefinitionId); var disabledFeatures = knownFeatures.Where(d => !activatedFeatureIds.Contains(d.Id)); result.AddRange(disabledFeatures.ToArray().Select(i => { return(ModelHostBase.Inherit <FeatureReverseHost>(parentHost, h => { h.Feature = null; h.FeatureId = i.Id; h.IsActivated = false; h.IsSiteLevel = isSiteLevel; h.IsWebLevel = isWebLevel; h.AllKnownFeatures = allKnownFeatures; })); })); return(result); }
protected override NavigationNodeCollection GetNavigationNodes(ReverseHostBase parentHost, ReverseOptions options) { var typedHost = parentHost.WithAssertAndCast <WebReverseHost>("reverseHost", value => value.RequireNotNull()); return(typedHost.HostWeb.Navigation.TopNavigationBar); }
public override IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options) { return(new[] { parentHost }); }
public abstract IEnumerable <ReverseHostBase> ReverseHosts(ReverseHostBase parentHost, ReverseOptions options);
protected override NavigationNodeCollection GetNavigationNodes(ReverseHostBase parentHost, ReverseOptions options) { var typedHost = parentHost.WithAssertAndCast<WebReverseHost>("reverseHost", value => value.RequireNotNull()); return typedHost.HostWeb.Navigation.QuickLaunch; }