public DateTimeConstantTranslation(ConstantExpression constant, ITranslationContext context) { Type = constant.Type; _value = (DateTime)constant.Value; _hasMilliseconds = _value.Millisecond != 0; _hasTime = (_value.Hour != 0) || (_value.Minute != 0) || (_value.Second != 0); var translationSize = "new DateTime(".Length + 4 + 4 + 4; var numericFormattingSize = context.GetFormattingSize(Numeric); var formattingSize = context.GetTypeNameFormattingSize() + numericFormattingSize * 3; if (_hasMilliseconds || _hasTime) { translationSize += 4 + 4 + 4; formattingSize += numericFormattingSize * 3; if (_hasMilliseconds) { translationSize += ", ".Length + 4; formattingSize += numericFormattingSize; } } TranslationSize = translationSize + 1; FormattingSize = formattingSize; }
protected ParameterTranslationBase( ParameterExpression parameter, string parameterName, ITranslationContext context) { _parameter = parameter; _parameterName = parameterName; TranslationSize = _parameterName.Length; FormattingSize = context.GetFormattingSize(Variable); }
public MethodGroupTranslation( ExpressionType nodeType, ITranslation subjectTranslation, MethodInfo subjectMethodInfo, ITranslationContext context) { NodeType = nodeType; Type = subjectMethodInfo.ReturnType; _subjectTranslation = subjectTranslation; _subjectMethodName = subjectMethodInfo.Name; TranslationSize = _subjectTranslation.TranslationSize + ".".Length + _subjectMethodName.Length; FormattingSize = _subjectTranslation.FormattingSize + context.GetFormattingSize(MethodName); }
public FixedValueTranslation( ExpressionType expressionType, string value, Type type, TokenType tokenType, ITranslationContext context) { NodeType = expressionType; Type = type; _value = value; _tokenType = tokenType; FormattingSize = context.GetFormattingSize(tokenType); }
public CommentTranslation(string comment, ITranslationContext context) { _comment = comment; FormattingSize = context.GetFormattingSize(TokenType.Comment); }
public static int GetControlStatementFormattingSize(this ITranslationContext context) => context.GetFormattingSize(TokenType.ControlStatement);
private int GetFormattingSize() => _subject?.FormattingSize ?? +_context.GetFormattingSize(TokenType.MethodName);