/// <summary> /// Register an implementation type for a content type that does not depend on services, and which /// can be initialized directly through deserialization. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="contentFactory">The content registry for this factory.</param> /// <remarks>The type must provide a static/const string called. <c>RegisteredContentType</c> which defines its content type.</remarks> public static void RegisterContent <T>(this ContentFactory contentFactory) where T : class { if (contentFactory == null) { throw new ArgumentNullException(nameof(contentFactory)); } string contentType = ContentFactory.GetContentType(typeof(T)); contentFactory.AddSimpleDeserializableType(contentType, typeof(T)); }
/// <summary> /// Register an implementation type for a content type that does not depend on services, and which /// can be initialized directly through deserialization. /// </summary> /// <typeparam name="T">The type to register.</typeparam> /// <param name="contentFactory">The content registry for this factory.</param> /// <param name="contentType">The content type by which to register it.</param> public static void RegisterContent <T>(this ContentFactory contentFactory, string contentType) where T : class { if (contentFactory == null) { throw new ArgumentNullException(nameof(contentFactory)); } if (string.IsNullOrEmpty(contentType)) { throw new ArgumentNullException(nameof(contentType)); } contentFactory.AddSimpleDeserializableType(contentType, typeof(T)); }