Ejemplo n.º 1
0
 public static ITypeConfiguration <T> Alter <T>(this ITypeConfiguration <T> @this, IAlteration <T> read,
                                                IAlteration <T> write)
 {
     @this.Root.With <AlteredContentExtension>()
     .Types.Assign(Support <T> .Key, new ContentAlteration(read.Adapt(), write.Adapt()));
     return(@this);
 }
Ejemplo n.º 2
0
 public static IMemberConfiguration <T, TMember> Alter <T, TMember>(this IMemberConfiguration <T, TMember> @this,
                                                                    IAlteration <TMember> read,
                                                                    IAlteration <TMember> write)
 {
     @this.Root.With <AlteredContentExtension>()
     .Members.Assign(@this.GetMember(), new ContentAlteration(read.Adapt(), write.Adapt()));
     return(@this);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Used to alter an instance of the configured result type whenever it is encountered during the serialization or
 /// deserialization process.  This can be used in scenarios where it is desired to know when an instance of a
 /// particular type is emitted or read (for logging purposes, etc.) or, more generally, to alter it in some way
 /// (scrubbing data, etc) before it is written to the external stream or read into memory.  You can consider this as a
 /// value interception of the serialization/deserialization pipeline.
 /// </summary>
 /// <typeparam name="T">The type under configuration.</typeparam>
 /// <param name="this">The type configuration to configure.</param>
 /// <param name="read">The alteration to apply during reading.</param>
 /// <param name="write">The alteration to apply during writing.</param>
 /// <returns>The configured type configuration.</returns>
 public static ITypeConfiguration <T> Alter <T>(this ITypeConfiguration <T> @this, IAlteration <T> read,
                                                IAlteration <T> write)
 => @this.Root.With <AlteredContentExtension>()
 .Types.Apply(Support <T> .Metadata, new ContentAlteration(read.Adapt(), write.Adapt()))
 .Return(@this);