/// <summary> /// <para>Assigns an <see cref="IJsonInterceptor"/> to process a specific type.</para> /// <para>This is a simplified version of <see cref="Override{T}(TypeOverride)"/> method replacing the <see cref="IJsonInterceptor"/> of a type.</para> /// </summary> /// <param name="type">The type to be processed by the interceptor.</param> /// <param name="interceptor">The interceptor to intercept the serialization and deserialization.</param> /// <remarks>If the type has already gotten an <see cref="IJsonInterceptor"/>, the new <paramref name="interceptor"/> will replace it. If the new interceptor is null, existing interceptor will be removed from the type.</remarks> public void OverrideInterceptor(Type type, IJsonInterceptor interceptor) { Override(type, new TypeOverride() { Interceptor = interceptor }, false); }
public RestServiceMethodInvoker( ISerializer serializer, IJsonInterceptor jsonInterceptor, ILogger logger) { _serializer = serializer; _jsonInterceptor = jsonInterceptor; _logger = logger; }
/// <summary> /// Marks a class or a struct to be processed by an <see cref="IJsonInterceptor"/>. /// </summary> /// <param name="interceptorType">The type of <see cref="IJsonInterceptor"/></param> /// <exception cref="JsonSerializationException">The exception will be thrown if the type does not implements <see cref="IJsonInterceptor"/>.</exception> public JsonInterceptorAttribute(Type interceptorType) { if (interceptorType == null) { throw new ArgumentNullException("interceptorType"); } if (interceptorType.IsInterface || typeof(IJsonInterceptor).IsAssignableFrom(interceptorType) == false) { throw new JsonSerializationException(String.Concat("The type ", interceptorType.FullName, " defined in ", typeof(JsonInterceptorAttribute).FullName, " does not implement interface ", typeof(IJsonInterceptor).FullName)); } Interceptor = Activator.CreateInstance(interceptorType) as IJsonInterceptor; }
/// <summary> /// <para>Assigns an <see cref="IJsonInterceptor"/> to process a specific type.</para> /// <para>This is a simplified version of <see cref="Override{T}(TypeOverride)"/> method replacing the <see cref="IJsonInterceptor"/> of a type.</para> /// </summary> /// <typeparam name="T">The type to be processed by the interceptor.</typeparam> /// <param name="interceptor">The interceptor to intercept the serialization and deserialization.</param> /// <remarks>If the type has already gotten an <see cref="IJsonInterceptor"/>, the new <paramref name="interceptor"/> will replace it. If the new interceptor is null, existing interceptor will be removed from the type.</remarks> public void OverrideInterceptor <T> (IJsonInterceptor interceptor) { Override(typeof(T), new TypeOverride { Interceptor = interceptor }, false); }
public RestServiceMethodInvoker(ISerializer serializer, IJsonInterceptor jsonInterceptor) { _serializer = serializer; _jsonInterceptor = jsonInterceptor; }
/// <summary> /// <para>Assigns an <see cref="IJsonInterceptor"/> to process a specific type.</para> /// <para>This is a simplified version of <see cref="Override{T}(TypeOverride)"/> method replacing the <see cref="IJsonInterceptor"/> of a type.</para> /// </summary> /// <typeparam name="T">The type to be processed by the interceptor.</typeparam> /// <param name="interceptor">The interceptor to intercept the serialization and deserialization.</param> /// <remarks>If the type has already gotten an <see cref="IJsonInterceptor"/>, the new <paramref name="interceptor"/> will replace it. If the new interceptor is null, existing interceptor will be removed from the type.</remarks> public void OverrideInterceptor <T> (IJsonInterceptor interceptor) { OverrideInterceptor(typeof(T), interceptor); }