Exemple #1
0
 public T GetImmediateParentOfType <T>(CodeElement item = null)
 {
     if (item == null)
     {
         return(GetImmediateParentOfType <T>(this));
     }
     else if (item is T p)
     {
         return(p);
     }
     else if (item.Parent == null)
     {
         throw new InvalidOperationException($"item {item.Name} of type {item.GetType()} does not have a parent");
     }
     else if (item.Parent is T p2)
     {
         return(p2);
     }
     else
     {
         return(GetImmediateParentOfType <T>(item.Parent));
     }
 }
Exemple #2
0
 public CodeMethod(CodeElement parent) : base(parent)
 {
 }
Exemple #3
0
 protected CodeTerminal(CodeElement parent) : base(parent)
 {
 }
Exemple #4
0
 public override string NormalizeFileName(CodeElement currentElement) => GetLastFileNameSegment(currentElement).ToFirstCharacterUpperCase();
Exemple #5
0
 public CodeBlock(CodeElement parent) : base(parent)
 {
     StartBlock = new BlockDeclaration(this);
     EndBlock   = new BlockEnd(this);
 }
Exemple #6
0
 public CodeUnionType(CodeElement parent) : base(parent)
 {
 }
 protected static string GetLastFileNameSegment(CodeElement currentElement) => currentElement.Name.Split('.').Last();
Exemple #8
0
 private CodeNamespace(CodeElement parent) : base(parent)
 {
 }
 public abstract string NormalizeFileName(CodeElement currentElement);
 public virtual IEnumerable <string> GetAdditionalSegment(CodeElement currentElement, string fileName) => Enumerable.Empty <string>();
Exemple #11
0
 public CodeClass(CodeElement parent) : base(parent)
 {
     StartBlock = new Declaration(this);
     EndBlock   = new End(this);
 }
Exemple #12
0
 public CodeEnum(CodeElement parent) : base(parent)
 {
 }
Exemple #13
0
 protected CodeTypeBase(CodeElement parent) : base(parent)
 {
 }
Exemple #14
0
 public CodeParameter(CodeElement parent) : base(parent)
 {
 }
Exemple #15
0
        public static async Task RenderCodeNamespaceToSingleFileAsync(LanguageWriter writer, CodeElement codeElement, string outputFile)
        {
            using var stream = new FileStream(outputFile, FileMode.Create);

            var sw = new StreamWriter(stream);

            writer.SetTextWriter(sw);
            RenderCode(writer, codeElement);
            await sw.FlushAsync();
        }
Exemple #16
0
 public CodeProperty(CodeElement parent) : base(parent)
 {
 }
Exemple #17
0
 public CodeUsing(CodeElement parent) : base(parent)
 {
 }