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