/// <summary> /// Assigns a default serialization monitor for a configuration container. A serialization monitor is a component /// that gets notified whenever there is a serialization such as OnSerializing, OnSerialized, as well as /// deserialization events such as OnDeserializing, OnDeserialized, etc. /// /// The default serialization monitor is applied for every type that is serialized with the serializer that the /// configured container creates. Use <see cref="WithMonitor{T}"/> on a type configuration to /// apply a monitor to a specific type. /// </summary> /// <param name="this">The configuration container to configure.</param> /// <param name="monitor">The monitor to assign as the default monitor.</param> /// <returns>The configured container.</returns> /// <seealso href="https://github.com/ExtendedXmlSerializer/home/issues/264"/> public static IConfigurationContainer WithDefaultMonitor(this IConfigurationContainer @this, ISerializationMonitor monitor) => @this.Extend(new SerializationMonitorExtension(monitor));
/// <summary> /// Applies a serialization monitor to a specific type. A serialization monitor is a component that gets notified /// whenever there is a serialization such as OnSerializing, OnSerialized, as well as deserialization events such as /// OnDeserializing, OnDeserialized, etc. /// /// Note that calling this method will establish a default monitor if one has not already been assigned. If you also /// want to use a default monitor in addition to type-specific monitors, call the <see cref="WithDefaultMonitor" /> /// first before calling this method on any types. /// </summary> /// <typeparam name="T">The type to monitor.</typeparam> /// <param name="this">The type configuration to configure.</param> /// <param name="monitor">The monitor to apply to the specified type.</param> /// <returns>The configured type configuration.</returns> /// <seealso href="https://github.com/ExtendedXmlSerializer/home/issues/264" /> public static ITypeConfiguration <T> WithMonitor <T>(this ITypeConfiguration <T> @this, ISerializationMonitor <T> monitor) => @this.Root.With <SerializationMonitorExtension>() .Apply(Support <T> .Metadata, new SerializationMonitor <T>(monitor)) .Return(@this);
public SerializationMonitor(ISerializationMonitor <T> monitor) => _monitor = monitor;