Пример #1
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 + '-');
     }
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent)
 {
     for (int i = 0; i < this.Length; i++)
     {
         ParameterValue parameterValue = new ParameterValue(this.Ctx, this.PC.Sequence[i], this.Values[i]);
         parameterValue.Spew(resOpt, to, indent + '-');
     }
 }
Пример #4
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);
 }
Пример #5
0
        public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            this.Referencing.Spew(resOpt, to, indent + "(referencing)", nameSort);
            List <ResolvedEntityReferenceSide> list = new List <ResolvedEntityReferenceSide>(this.Referenced);

            if (nameSort)
            {
                list.Sort((l, r) => StringUtils.CompareWithOrdinalIgnoreCase(l.Entity?.GetName(), r.Entity?.GetName()));
            }

            for (int i = 0; i < this.Referenced.Count; i++)
            {
                list[i].Spew(resOpt, to, indent + $"(referenced[{i}])", nameSort);
            }
        }
Пример #6
0
        public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            List <ResolvedTrait> list = new List <ResolvedTrait>(this.Set);

            if (nameSort)
            {
                list.Sort((l, r) => StringUtils.CompareWithOrdinalIgnoreCase(l.TraitName, r.TraitName));
            }

            for (int i = 0; i < this.Set.Count; i++)
            {
                list[i].Spew(resOpt, to, indent);
            }
            ;
        }
Пример #7
0
        public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            if (this.Set.Count > 0)
            {
                List <ResolvedAttribute> list = new List <ResolvedAttribute>(this.Set);
                if (nameSort)
                {
                    list = this.Set.OrderBy(att => Regex.Replace(att.ResolvedName.ToLowerInvariant(), "[^a-zA-Z0-9.]+", "", RegexOptions.Compiled)).ToList();
                }

                for (int i = 0; i < this.Set.Count; i++)
                {
                    list[i].Spew(resOpt, to, indent, nameSort);
                }
            }
        }
Пример #8
0
        public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            if (this.Set.Count > 0)
            {
                List <ResolvedAttribute> list = new List <ResolvedAttribute>(this.Set);
                if (nameSort)
                {
                    list.Sort((l, r) => string.Compare(l.ResolvedName, r.ResolvedName, StringComparison.OrdinalIgnoreCase));
                }

                for (int i = 0; i < this.Set.Count; i++)
                {
                    list[i].Spew(resOpt, to, indent, nameSort);
                }
            }
        }
Пример #9
0
        internal void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            List <ResolvedEntityReference> list;

            if (nameSort)
            {
                list = this.Set.OrderBy(rer => rer.Referenced?.Count > 0 ? rer.Referenced[0].Entity?.GetName().ToLowerInvariant() : "").ToList();
            }
            else
            {
                list = new List <ResolvedEntityReference>(this.Set);
            }

            for (int i = 0; i < this.Set.Count; i++)
            {
                list[i].Spew(resOpt, to, indent + $"(rer[{i}])", nameSort);
            }
        }
Пример #10
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}");
     }
 }
Пример #11
0
        internal void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
        {
            List <ResolvedEntityReference> list = new List <ResolvedEntityReference>(this.Set);

            if (nameSort)
            {
                list.Sort((l, r) => {
                    if (l.Referenced?.Count > 0)
                    {
                        if (r.Referenced?.Count > 0)
                        {
                            return(StringUtils.CompareWithOrdinalIgnoreCase(l.Referenced[0].Entity?.GetName(), r.Referenced[0].Entity?.GetName()));
                        }
                        return(1);
                    }
                    return(-1);
                });
            }
            for (int i = 0; i < this.Set.Count; i++)
            {
                list[i].Spew(resOpt, to, indent + $"(rer[{i}])", nameSort);
            }
        }
Пример #12
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)
        {
            // make sure the corpus has a set of default artifact attributes
            await cdmCorpus.PrepareArtifactAttributesAsync();

            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()
                        {
                            ImportsLoadStrategy = ImportsLoadStrategy.Load
                        };
                        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("");
        }
Пример #13
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent, bool nameSort)
 {
     to.SpewLine($"{ indent}[{this._resolvedName}]");
     this.ResolvedTraits.Spew(resOpt, to, indent + '-', nameSort);
 }
Пример #14
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);
            }
        }
Пример #15
0
 public void Spew(ResolveOptions resOpt, StringSpewCatcher to, string indent)
 {
     to.SpewLine($"{indent}{this.Name}:{this.FetchValueString(resOpt)}");
 }