Пример #1
0
 public Expression Serialize(FormatContextWithValue context)
 => WriteMethod != null
             ? Expression.Call(context.Buffer, WriteMethod, context.Value)
             : throw new InvalidOperationException($"No serializator method was found for type {Type.FullName}");
Пример #2
0
 Expression ITypeFormat.Serialize(FormatContextWithValue context)
 => Expression.Call(Expression.Constant(this), nameof(Serialize), null, context.Buffer, context.Value);
Пример #3
0
 /// <summary>
 /// Shortcut for <c>context.Write(typeof(T), value)</c>
 /// </summary>
 public static Expression Write <T>(this FormatContextWithValue context, Expression value)
 => context.Write(typeof(T), value);
Пример #4
0
 public abstract Expression Serialize(FormatContextWithValue context);
Пример #5
0
 /// <summary>
 /// Shortcut for <c>context.GetFormat(type).Serialize(context.WithType(type).WithValue(value))</c>
 /// </summary>
 public static Expression Write(this FormatContextWithValue context, Type type, Expression value)
 => context.Formats.Get(type).Serialize(context.WithType(type).WithValue(value));