Ejemplo n.º 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}");
Ejemplo n.º 2
0
 Expression ITypeFormat.Serialize(FormatContextWithValue context)
 => Expression.Call(Expression.Constant(this), nameof(Serialize), null, context.Buffer, context.Value);
Ejemplo n.º 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);
Ejemplo n.º 4
0
 public abstract Expression Serialize(FormatContextWithValue context);
Ejemplo n.º 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));