/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration writer.WriteLine("{0} {1} {2}{3} {4}", TokenUtility.ToString(this.Visibility), this.ReturnType.Translate(), this.Name.Translate(), SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())), Lexems.OpenCurlyBracket); // Statements // The body, we render them as a list of semicolon/newline separated elements writer.WriteLine("{0}", SyntaxUtility.ToNewlineSemicolonSeparatedList( this.statements.Select(unit => unit.Translate()), true)); // Closing declaration writer.WriteLine("{0}", Lexems.CloseCurlyBracket); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration: <visibility> constructor(<params>) { writer.WriteLine("{0}{1} {2}", Lexems.ConstructorKeyword, SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())), Lexems.OpenCurlyBracket); // Statements // The body, we render them as a list of semicolon/newline separated elements foreach (ITranslationUnit statement in this.statements) { writer.WriteLine("{0}{1}", statement.Translate(), ShouldRenderSemicolon(statement) ? Lexems.Semicolon : string.Empty); } // Closing declaration writer.WriteLine("{0}", Lexems.CloseCurlyBracket); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration: [<visibility>] <method-name>(<params>) : <type> string classVisibility = this.RenderedVisibilityModifier; if (this.ShouldRenderReturnType) { writer.WriteLine("{0}{1}{2} {3} {4}", classVisibility, this.RenderedName, SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate())), Lexems.Colon, this.ReturnType.Translate()); } else { writer.WriteLine("{0}{1}{2}", classVisibility, this.RenderedName, SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate()))); } return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Invokation: ([<initializers>]) writer.WriteLine("{0}", SyntaxUtility.ToSquareBracketEnclosedList(this.arguments.Select(unit => unit.Translate())) ); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Invokation: <expression>([<params>]) writer.WriteLine("{0}{1}", this.expression.Translate(), SyntaxUtility.ToSquareBracketEnclosedList(this.arguments.Select(unit => unit.Translate())) ); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration writer.WriteLine("{0} {1} {2}{3}", TokenUtility.ToString(this.Visibility), this.ReturnType.Translate(), this.Name.Translate(), SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate()))); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration: [<visibility>] <method-name>(<params>) : <type> { // TODO: Handle case of no visibility specified string methodVisibility = this.RenderedVisibilityModifier; if (this.ShouldRenderReturnType) { writer.WriteLine("{0}{1}{2} {3} {4} {5}", methodVisibility, this.RenderedName, SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())), Lexems.Colon, this.ReturnType.Translate(), Lexems.OpenCurlyBracket); } else { writer.WriteLine("{0}{1}{2} {3}", methodVisibility, this.RenderedName, SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())), Lexems.OpenCurlyBracket); } // Statements // The body, we render them as a list of semicolon/newline separated elements foreach (ITranslationUnit statement in this.statements) { writer.WriteLine("{0}{1}", statement.Translate(), ShouldRenderSemicolon(statement) ? Lexems.Semicolon : string.Empty); } // Closing declaration writer.WriteLine("{0}", Lexems.CloseCurlyBracket); return(writer.ToString()); }
/// <summary> /// /// </summary> /// <returns></returns> private string BuildClassInheritanceAndInterfaceImplementationList() { string baseClass = string.Empty; if (this.BaseClassName != null) { baseClass = string.Format("{0} {1}", Lexems.ExtendsKeyword, this.BaseClassName.Translate()); } string implementationList = this.Interfaces.Count() > 0 ? string.Format("{0} {1}", Lexems.ImplementsKeyword, SyntaxUtility.ToTokenSeparatedList( this.Interfaces.Select(unit => unit.Translate()), Lexems.Comma + " ")) : string.Empty; return(string.Format("{0} {1}", baseClass, implementationList)); }
/// <summary> /// /// </summary> /// <returns></returns> private string BuildInterfaceExtensionList() { string implementationList = this.Interfaces.Count() > 0 ? string.Format("{0} {1}", Lexems.ExtendsKeyword, SyntaxUtility.ToTokenSeparatedList( this.Interfaces.Select(unit => unit.Translate()), Lexems.Comma + " ")) : string.Empty; return(implementationList); }