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); }
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<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; }