public void WriteTo(TranslationWriter writer) { _subject.WriteTo(writer); writer.WriteToTranslation('['); _parameters.WithoutParentheses().WriteTo(writer); writer.WriteToTranslation(']'); }
public void WriteTo(TranslationWriter writer) { writer.WriteNewToTranslation(); writer.WriteTypeNameToTranslation(nameof(DateTime)); writer.WriteToTranslation('('); writer.WriteToTranslation(_value.Year); WriteTwoDigitDatePart(_value.Month, writer); WriteTwoDigitDatePart(_value.Day, writer); if (_hasMilliseconds || _hasTime) { WriteTwoDigitDatePart(_value.Hour, writer); WriteTwoDigitDatePart(_value.Minute, writer); WriteTwoDigitDatePart(_value.Second, writer); if (_hasMilliseconds) { writer.WriteToTranslation(", "); writer.WriteToTranslation(_value.Millisecond); } } writer.WriteToTranslation(")"); }
public void WriteTo(TranslationWriter writer) { writer.WriteNewToTranslation(); _typeNameTranslation.WriteTo(writer); writer.WriteToTranslation('['); if (_boundTranslationCount != 0) { for (var i = 0; ;) { _boundTranslations[i].WriteTo(writer); ++i; if (i == _boundTranslationCount) { break; } writer.WriteToTranslation("[]"); } } writer.WriteToTranslation(']'); }
public void WriteTo(TranslationWriter writer) { writer.WriteNewLineToTranslation(); writer.WriteKeywordToTranslation("catch"); _exceptionClause?.WriteTo(writer); _catchBodyTranslation.WriteTo(writer); }
private static bool TryWriteFactoryMethodCall( long value, double totalValue, string valueName, TranslationWriter writer) { if (value == 0) { return(false); } // ReSharper disable once CompareOfFloatsByEqualityOperator if (value != totalValue) { return(false); } var factoryMethodName = "From" + valueName; writer.WriteTypeNameToTranslation(nameof(TimeSpan)); writer.WriteDotToTranslation(); writer.WriteToTranslation(factoryMethodName, MethodName); writer.WriteToTranslation('('); writer.WriteToTranslation(value); writer.WriteToTranslation(')'); return(true); }
public override void WriteTo(TranslationWriter writer) { WriteIfStatement(writer); writer.WriteNewLineToTranslation(); writer.WriteNewLineToTranslation(); IfFalseTranslation.WriteTo(writer); }
private void WriteGenericArgumentNamesIfNecessary(TranslationWriter writer) { if (_explicitGenericArgumentCount == 0) { return; } writer.WriteToTranslation('<'); for (var i = 0; ;) { _explicitGenericArguments[i].WriteTo(writer); ++i; if (i == _explicitGenericArgumentCount) { break; } writer.WriteToTranslation(", "); } writer.WriteToTranslation('>'); }
public void WriteTo(TranslationWriter writer) { for (var i = 0; ;) { var operandTranslation = _operandTranslations[i]; if ((operandTranslation.NodeType == ExpressionType.Conditional) || operandTranslation.IsAssignment()) { operandTranslation.WriteInParentheses(writer); } else { operandTranslation.WriteTo(writer); } ++i; if (i == _operandCount) { break; } writer.WriteToTranslation(" + "); } }
public void WriteTo(TranslationWriter writer) { if (TryWriteFactoryMethodCall(_timeSpan.Days, _timeSpan.TotalDays, "Days", writer)) { return; } if (TryWriteFactoryMethodCall(_timeSpan.Hours, _timeSpan.TotalHours, "Hours", writer)) { return; } if (TryWriteFactoryMethodCall(_timeSpan.Minutes, _timeSpan.TotalMinutes, "Minutes", writer)) { return; } if (TryWriteFactoryMethodCall(_timeSpan.Seconds, _timeSpan.TotalSeconds, "Seconds", writer)) { return; } if (TryWriteFactoryMethodCall(_timeSpan.Milliseconds, _timeSpan.TotalMilliseconds, "Milliseconds", writer)) { return; } if ((_timeSpan.Days == 0) && (_timeSpan.Hours == 0) && (_timeSpan.Minutes == 0) && (_timeSpan.Seconds == 0)) { writer.WriteTypeNameToTranslation(nameof(TimeSpan)); writer.WriteDotToTranslation(); writer.WriteToTranslation("FromTicks", MethodName); writer.WriteToTranslation('('); writer.WriteToTranslation(Math.Floor(_timeSpan.TotalMilliseconds * 10000).ToString(CurrentCulture)); goto EndTranslation; } writer.WriteNewToTranslation(); writer.WriteTypeNameToTranslation(nameof(TimeSpan)); writer.WriteToTranslation('('); if (_timeSpan.Days == 0) { WriteTimeSpanHoursMinutesSeconds(writer, _timeSpan); goto EndTranslation; } writer.WriteToTranslation(_timeSpan.Days); writer.WriteToTranslation(", "); WriteTimeSpanHoursMinutesSeconds(writer, _timeSpan); if (_timeSpan.Milliseconds != 0) { writer.WriteToTranslation(", "); writer.WriteToTranslation(_timeSpan.Milliseconds); } EndTranslation: writer.WriteToTranslation(')'); }
public virtual void WriteTo(TranslationWriter writer) { writer.WriteToTranslation(" ("); _exceptionTypeTranslation.WriteTo(writer); writer.WriteSpaceToTranslation(); writer.WriteToTranslation(_variableName, Variable); writer.WriteToTranslation(')'); }
public void WriteTo(TranslationWriter writer) { _parameters.WriteTo(writer); writer.WriteToTranslation(_bodyTranslation.HasBraces ? " =>" : _fatArrow); _bodyTranslation.WriteTo(writer); }
private static void WriteTimeSpanHoursMinutesSeconds(TranslationWriter writer, TimeSpan timeSpan) { writer.WriteToTranslation(timeSpan.Hours); writer.WriteToTranslation(", "); writer.WriteToTranslation(timeSpan.Minutes); writer.WriteToTranslation(", "); writer.WriteToTranslation(timeSpan.Seconds); }
public void WriteTo(TranslationWriter writer) { writer.WriteControlStatementToTranslation("while "); writer.WriteToTranslation('('); writer.WriteKeywordToTranslation("true"); writer.WriteToTranslation(')'); _loopBodyTranslation.WriteTo(writer); }
private void WriteSingleLineTernary(TranslationWriter writer) { TestTranslation.WriteInParenthesesIfRequired(writer, _context); writer.WriteToTranslation(" ? "); IfTrueTranslation.WriteTo(writer); writer.WriteToTranslation(" : "); IfFalseTranslation.WriteTo(writer); }
public void WriteTo(TranslationWriter writer) { _binaryConditionLeftTranslation.WriteInParenthesesIfRequired(writer, _context); writer.WriteToTranslation(_binaryConditionOperator.TrimEnd()); writer.WriteNewLineToTranslation(); writer.Indent(); _binaryConditionRightTranslation.WriteInParenthesesIfRequired(writer, _context); writer.Unindent(); }
protected virtual void WriteStatementTo(TranslationWriter writer) { _statementTranslation.WriteTo(writer); if (_statementIsUnterminated && (DoNotTerminate == false)) { writer.WriteToTranslation(';'); } }
public override void WriteTo(TranslationWriter writer) { if (this.ExceedsLengthThreshold()) { WriteMultiLineTernary(writer); return; } WriteSingleLineTernary(writer); }
private bool WriteEmptyCodeBlock(TranslationWriter writer) { if (_isEmptyTranslation) { writer.WriteClosingBraceToTranslation(startOnNewLine: false); return(true); } return(false); }
public void WriteTo(TranslationWriter writer) { if (_typeNameTranslation != null) { _typeNameTranslation.WriteTo(writer); writer.WriteSpaceToTranslation(); } writer.WriteToTranslation(_parameterName, Variable); }
public void WriteTo(TranslationWriter writer) { if (_subject != null) { _subject.WriteInParenthesesIfRequired(writer, _context); writer.WriteDotToTranslation(); } writer.WriteToTranslation(_memberName); }
public static void WriteClosingBraceToTranslation(this TranslationWriter writer, bool startOnNewLine = true) { if (startOnNewLine) { writer.WriteNewLineToTranslation(); } writer.Unindent(); writer.WriteToTranslation('}'); }
public static void WriteOpeningBraceToTranslation(this TranslationWriter writer, bool startOnNewLine = true) { if (startOnNewLine && writer.TranslationQuery(q => !q.TranslationEndsWith('{'))) { writer.WriteNewLineToTranslation(); } writer.WriteToTranslation('{'); writer.WriteNewLineToTranslation(); writer.Indent(); }
public void WriteTo(TranslationWriter writer) { writer.WriteKeywordToTranslation(_throw); if (_thrownItemTranslation == null) { return; } writer.WriteSpaceToTranslation(); _thrownItemTranslation.WriteTo(writer); }
public override void WriteTo(TranslationWriter writer) { WriteIfStatement(writer); writer.WriteNewLineToTranslation(); writer.WriteControlStatementToTranslation("else"); if (_isElseIf) { writer.WriteSpaceToTranslation(); } IfFalseTranslation.WriteTo(writer); }
private static void WriteTwoDigitDatePart(int datePart, TranslationWriter writer) { writer.WriteToTranslation(", "); if (datePart > 9) { writer.WriteToTranslation(datePart); return; } writer.WriteToTranslation(0); writer.WriteToTranslation(datePart); }
public static void WriteInParenthesesIfRequired( this ITranslation translation, TranslationWriter writer, ITranslationContext context) { if (ShouldWriteInParentheses(translation)) { translation.WriteInParentheses(writer); return; } new CodeBlockTranslation(translation, context).WriteTo(writer); }
public void WriteTo(TranslationWriter writer) { _initializers.IsLongTranslation = TranslationSize > 40; writer.WriteNewToTranslation(); if (_typeName.Length != 0) { writer.WriteTypeNameToTranslation(_typeName); writer.WriteSpaceToTranslation(); } _initializers.WriteTo(writer); }
private void WriteDefaultIfPresent(TranslationWriter writer) { if (_defaultCaseTranslation == null) { return; } writer.WriteNewLineToTranslation(); writer.WriteNewLineToTranslation(); writer.WriteControlStatementToTranslation("default:"); writer.WriteNewLineToTranslation(); WriteCaseBody(_defaultCaseTranslation, writer); }
private static void WriteCaseBody(ITranslation bodyTranslation, TranslationWriter writer) { writer.Indent(); bodyTranslation.WriteTo(writer); if (WriteBreak(bodyTranslation)) { writer.WriteNewLineToTranslation(); writer.WriteControlStatementToTranslation("break;"); } writer.Unindent(); }
protected override void WriteStatementTo(TranslationWriter writer) { if (_typeNameTranslation != null) { _typeNameTranslation.WriteTo(writer); } else { writer.WriteKeywordToTranslation(_var); } writer.WriteSpaceToTranslation(); base.WriteStatementTo(writer); }