/// <summary> /// Adds an extension to the provided context by invoking the provided factory method and adding it to the context. /// </summary> /// <typeparam name="T">The serializer extension type to create and add.</typeparam> /// <param name="this">The configuration context (usually a configuration container) with which to add the created /// serializer extension.</param> /// <param name="create">The factory used to create the extension of the requested type.</param> /// <returns>The created and added extension.</returns> public static T Add <T>(this IRootContext @this, Func <T> create) where T : ISerializerExtension => @this.Apply(create()).AsValid <T>();
/// <summary> /// Used to apply a new serializer extension of the provided type. If an extension already exists in the provided /// context, it is returned. Otherwise, it will attempt to locate a singleton on the provided type, and if that isn't /// found, activate it by calling its public constructor. /// </summary> /// <typeparam name="T">The serializer extension type to apply.</typeparam> /// <param name="this">The configuration context (usually a configuration container) to locate the provided serializer /// extension type.</param> /// <returns>The configured context with the requested extension applied to it.</returns> public static IRootContext Apply <T>(this IRootContext @this) where T : class, ISerializerExtension => @this.Apply(Support <T> .NewOrSingleton);