/// <summary> /// Get the text version of all the resolved entities. /// </summary> /// <param name="cdmCorpus"> The CDM corpus. </param> /// <param name="directives"> The directives to use while getting the resolved entities. </param> /// <param name="manifest"> The manifest to be resolved. </param> /// <param name="spew"> The object used to store the text to be returned. </param> /// <returns> The text version of the resolved entities. (it's in a form that facilitates debugging) </returns> internal static async Task <string> ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null) { var seen = new HashSet <string>(); Func <CdmManifestDefinition, Task> seekEntities = null; seekEntities = async(CdmManifestDefinition f) => { if (f.Entities != null) { if (spew != null) { spew.SpewLine(f.FolderPath); } foreach (CdmEntityDeclarationDefinition entity in f.Entities) { string corpusPath; CdmEntityDeclarationDefinition ent = entity; CdmObject currentFile = f; while (ent is CdmReferencedEntityDeclarationDefinition) { corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile); ent = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath); currentFile = ent; } corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile); ResolveOptions resOpt = new ResolveOptions() { StrictValidation = true }; CdmEntityDefinition newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath, null, resOpt); resOpt.WrtDoc = newEnt.InDocument; resOpt.Directives = directives; ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt); if (spew != null) { resEnt.Spew(resOpt, spew, " ", true); } } } if (f.SubManifests != null) { // folder.SubManifests.ForEach(async f => foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests) { string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f); await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath)); } } }; await seekEntities(manifest); if (spew != null) { return(spew.GetContent()); } return(""); }
public async static Task ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null) { ISet <string> seen = new HashSet <string>(); Func <CdmManifestDefinition, Task> seekEntities = null; seekEntities = async(CdmManifestDefinition f) => { if (f.Entities != null) { if (spew != null) { spew.SpewLine(f.FolderPath); } // manifest.Entities.ForEach(async entity => foreach (CdmEntityDeclarationDefinition entity in f.Entities) { string corpusPath; CdmEntityDeclarationDefinition ent = entity; CdmObject currentFile = f; while (ent is CdmReferencedEntityDeclarationDefinition) { corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile); ent = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath); currentFile = (CdmObject)ent; } corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile); var newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath); ResolveOptions resOpt = new ResolveOptions() { WrtDoc = newEnt.InDocument, Directives = directives }; ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt); if (spew != null) { resEnt.Spew(resOpt, spew, " ", true); } } } if (f.SubManifests != null) { // folder.SubManifests.ForEach(async f => foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests) { string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f); await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath)); } } }; await seekEntities(manifest); if (spew != null) { File.WriteAllText(@"c:\temp\allResolved.txt", spew.GetContent(), Encoding.UTF8); } }