/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration string fieldVisibility = this.RenderedVisibilityModifier; if (this.Expression == null) { writer.Write("{0}{1} {2} {3}{4}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.Visibility.ConvertToTypeScriptEquivalent().EmitOptionalVisibility(), this.RenderedName, Lexems.Colon, this.type.Translate(), Lexems.Newline); } else { writer.Write("{0}{1} {2} {3} {4} {5}{6}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.Visibility.ConvertToTypeScriptEquivalent().EmitOptionalVisibility(), this.RenderedName, Lexems.Colon, this.type.Translate(), Lexems.EqualsSign, this.Expression.Translate(), Lexems.Newline); } 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 if (this.type != null) { writer.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.name.Translate(), Lexems.Colon, this.type.Translate()); } else { writer.Write("{0} {1}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.name.Translate()); } return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // TODO: Improve this logic to make it more readable and efficient if (this.type != null) { if (this.Expression == null) { // [var ]<name> : <type> writer.Write("{0}{1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.shouldRenderDeclarationKeyword ? "let " : string.Empty, this.names[0].Translate(), Lexems.Colon, this.type.Translate()); } else { // [var ]<name> : <type> = <expression> writer.Write("{0}{1} {2} {3} {4} {5}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.shouldRenderDeclarationKeyword ? "let " : string.Empty, this.names[0].Translate(), Lexems.Colon, this.type.Translate(), Lexems.EqualsSign, this.Expression.Translate()); } } else { if (this.Expression == null) { // var <name> writer.Write("{0} {1}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.names[0].Translate()); } else { // var <name> = <expression> writer.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.names[0].Translate(), Lexems.EqualsSign, this.Expression.Translate()); } } return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}", keyword); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}", this.variableDeclaration.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; if (this.accessMethod == MemberAccessMethod.None) { writer.Write("{0}", this.Member.Translate()); } else { writer.Write("{0}{1}{2}", MemberAccessMethod2String(this.accessMethod), Lexems.Dot, this.Member.Translate()); } return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; if (this.value != null) { writer.Write("{0} {1} {2}", this.name.Translate(), Lexems.EqualsSign, this.value.Translate()); } else { writer.Write("{0}", this.name.Translate()); } return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0} {1}", this.commentToken, this.comment); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write(this.unaryPosition == UnaryPosition.Postfix ? "{0}{1}" : "{1}{0}", this.Operand.Translate(), TokenUtility.ToString(this.operatorToken)); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}", this.keyword != null ? keyword + " " : string.Empty, this.expression.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}{2}", Lexems.OpenRoundBracket, this.WrappedExpression.Translate(), Lexems.CloseRoundBracket); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; string commentBody = $"<reference path=\"{this.path}\" />"; ITranslationUnit commentTranslationUnit = SingleLineCommentTranslationUnit.Create(commentBody, SingleLineCommentTranslationUnit.CommentStyle.XmlStyle); writer.Write("{0}", commentTranslationUnit.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}{2}{3}", Lexems.OpenAngularBracket, this.Type.Translate(), Lexems.CloseAngularBracket, this.Castee.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; string commentBody = $"<reference path=\"{this.path}\" />"; ITranslationUnit commentTranslationUnit = SingleLineCommentTranslationUnit.Create(commentBody, SingleLineCommentTranslationUnit.CommentStyle.XmlStyle); writer.Write("{0}", commentTranslationUnit.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.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), TokenUtility.ToString(this.Visibility), this.Name.Translate(), Lexems.Colon, this.type.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // TODO: Use `{0}{1}{2}{1}{3}` when FormatWriter gets fixed to support repetitive placeholders writer.Write("{0}{1}{2}{3}{4}", this.LeftOperand.Translate(), Lexems.Whitespace, TokenUtility.ToString(this.operatorToken), Lexems.Whitespace, this.RightOperand.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 string fieldVisibility = this.RenderedVisibilityModifier; writer.Write("{0}{1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.Modifiers.ConvertToTypeScriptEquivalent().EmitOptionalVisibility(), this.RenderedName, Lexems.Colon, this.type.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}", this.variableDeclaration.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.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), TokenUtility.ToString(this.Visibility), this.Name.Translate(), Lexems.Colon, this.type.Translate()); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0} {1}", this.commentToken, this.comment); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}{2}{3}", Lexems.OpenAngularBracket, this.Type.Translate(), Lexems.CloseAngularBracket, this.Castee.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 if (this.type != null) { writer.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.name.Translate(), Lexems.Colon, this.type.Translate()); } else { writer.Write("{0} {1}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.name.Translate()); } return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; if (this.accessMethod == MemberAccessMethod.None) { writer.Write("{0}", this.Member.Translate()); } else { writer.Write("{0}{1}{2}", MemberAccessMethod2String(this.accessMethod), Lexems.Dot, this.Member.Translate()); } return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write(this.unaryPosition == UnaryPosition.Postfix ? "{0}{1}" : "{1}{0}", this.Operand.Translate(), TokenUtility.ToString(this.operatorToken)); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // TODO: Use `{0}{1}{2}{1}{3}` when FormatWriter gets fixed to support repetitive placeholders writer.Write("{0}{1}{2}{3}{4}", this.LeftOperand.Translate(), Lexems.Whitespace, TokenUtility.ToString(this.operatorToken), Lexems.Whitespace, this.RightOperand.Translate()); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}{2}", Lexems.OpenRoundBracket, this.WrappedExpression.Translate(), Lexems.CloseRoundBracket); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}", keyword); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // TODO: Improve this logic to make it more readable and efficient if (this.type != null) { if (this.Expression == null) { // [var ]<name> : <type> writer.Write("{0}{1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.shouldRenderDeclarationKeyword ? Lexems.VariableDeclaratorKeyword + " " : string.Empty, this.names[0].Translate(), Lexems.Colon, this.type.Translate()); } else { // [var ]<name> : <type> = <expression> writer.Write("{0}{1} {2} {3} {4} {5}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.shouldRenderDeclarationKeyword ? Lexems.VariableDeclaratorKeyword + " " : string.Empty, this.names[0].Translate(), Lexems.Colon, this.type.Translate(), Lexems.EqualsSign, this.Expression.Translate()); } } else { if (this.Expression == null) { // var <name> writer.Write("{0} {1}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.names[0].Translate()); } else { // var <name> = <expression> writer.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.VariableDeclaratorKeyword, this.names[0].Translate(), Lexems.EqualsSign, this.Expression.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 string fieldVisibility = this.RenderedVisibilityModifier; writer.Write("{0}{1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.Visibility.ConvertToTypeScriptEquivalent().EmitOptionalVisibility(), this.RenderedName, Lexems.Colon, this.type.Translate()); return writer.ToString(); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write("{0}{1}", this.keyword != null ? keyword + " " : string.Empty, this.expression.Translate()); return writer.ToString(); }