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)); } }
public CodeMethod(CodeElement parent) : base(parent) { }
protected CodeTerminal(CodeElement parent) : base(parent) { }
public override string NormalizeFileName(CodeElement currentElement) => GetLastFileNameSegment(currentElement).ToFirstCharacterUpperCase();
public CodeBlock(CodeElement parent) : base(parent) { StartBlock = new BlockDeclaration(this); EndBlock = new BlockEnd(this); }
public CodeUnionType(CodeElement parent) : base(parent) { }
protected static string GetLastFileNameSegment(CodeElement currentElement) => currentElement.Name.Split('.').Last();
private CodeNamespace(CodeElement parent) : base(parent) { }
public abstract string NormalizeFileName(CodeElement currentElement);
public virtual IEnumerable <string> GetAdditionalSegment(CodeElement currentElement, string fileName) => Enumerable.Empty <string>();
public CodeClass(CodeElement parent) : base(parent) { StartBlock = new Declaration(this); EndBlock = new End(this); }
public CodeEnum(CodeElement parent) : base(parent) { }
protected CodeTypeBase(CodeElement parent) : base(parent) { }
public CodeParameter(CodeElement parent) : base(parent) { }
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(); }
public CodeProperty(CodeElement parent) : base(parent) { }
public CodeUsing(CodeElement parent) : base(parent) { }