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; }
private TimeSpanConstantTranslation( ConstantExpression timeSpanConstant, ITranslationContext context) { Type = timeSpanConstant.Type; _timeSpan = (TimeSpan)timeSpanConstant.Value; TranslationSize = _timeSpan.ToString().Length; var formattingSize = context.GetTypeNameFormattingSize(); FormattingSize = formattingSize; }
public MethodInvocationTranslation(IMethod method, ParameterSetTranslation parameters, ITranslationContext context) { _method = method; _parameters = parameters; _explicitGenericArguments = GetRequiredExplicitGenericArguments(context, out var translationsSize); _explicitGenericArgumentCount = _explicitGenericArguments.Length; TranslationSize = method.Name.Length + translationsSize + parameters.TranslationSize; FormattingSize = _explicitGenericArgumentCount * context.GetTypeNameFormattingSize() + parameters.FormattingSize; }
public DbNullTranslation(Expression dbNull, ITranslationContext context) { Type = dbNull.Type; TranslationSize = "DBNull.Value".Length; FormattingSize = context.GetTypeNameFormattingSize(); }