Exemple #1
0
        /// <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("");
        }
Exemple #2
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent)
 {
     to.SpewLine($"{indent}[{this.TraitName}]");
     if (this.ParameterValues != null)
     {
         this.ParameterValues.Spew(resOpt, to, indent + '-');
     }
 }
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
 {
     to.SpewLine($"{indent} ent={this.Entity?.GetName()}");
     if (this.ResolvedAttributeSetBuilder?.ResolvedAttributeSet != null)
     {
         this.ResolvedAttributeSetBuilder.ResolvedAttributeSet.Spew(resOpt, to, indent + "  atts:", nameSort);
     }
 }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
 public void SpewProperties(StringSpewCatcher to, string indent)
 {
     if (this.DisplayName != null)
     {
         to.SpewLine($"{indent}displayName: {this.DisplayName}");
     }
     if (this.Description != null)
     {
         to.SpewLine($"{indent}description: {this.Description}");
     }
     if (this.Version != null)
     {
         to.SpewLine($"{indent}version: {this.Version}");
     }
     if (this.SourceName != null)
     {
         to.SpewLine($"{indent}sourceName: {this.SourceName}");
     }
 }
Exemple #6
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
 {
     to.SpewLine(indent + "=====ENTITY=====");
     to.SpewLine(indent + this.ResolvedName);
     to.SpewLine(indent + "================");
     to.SpewLine($"{indent}properties:");
     this.SpewProperties(to, $"{indent} ");
     to.SpewLine(indent + "traits:");
     this.ResolvedTraits.Spew(resOpt, to, indent + " ", nameSort);
     to.SpewLine("attributes:");
     this.ResolvedAttributes.Spew(resOpt, to, indent + " ", nameSort);
     to.SpewLine("relationships:");
     this.ResolvedEntityReferences.Spew(resOpt, to, indent + " ", nameSort);
 }
Exemple #7
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
 {
     to.SpewLine($"{ indent}[{this._resolvedName}]");
     this.ResolvedTraits.Spew(resOpt, to, indent + '-', nameSort);
 }
Exemple #8
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent)
 {
     to.SpewLine($"{indent}{this.Name}:{this.FetchValueString(resOpt)}");
 }