public static ITypeSerializerStrategy Get([NotNull] this IContextualSerializerProvider provider, ContextTypeFlags contextFlags, [NotNull] IContextKey key, [NotNull] Type type) { if (provider == null) { throw new ArgumentNullException(nameof(provider), $"Cannot call extension method on null {nameof(IContextualSerializerProvider)}"); } if (key == null) { throw new ArgumentNullException(nameof(key)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } if (!Enum.IsDefined(typeof(ContextTypeFlags), contextFlags)) { throw new ArgumentOutOfRangeException(nameof(contextFlags), "Value should be defined in the ContextTypeFlags enum."); } /*if (!Enum.IsDefined(typeof(ContextTypeFlags), contextFlags)) * throw new InvalidEnumArgumentException(nameof(contextFlags), (int) contextFlags, typeof(ContextTypeFlags));*/ return(provider.Get(new ContextualSerializerLookupKey(contextFlags, key, type))); }
public ContextualLazyStrategyProvider(IContextualSerializerProvider provider, ContextualSerializerLookupKey key) { SerializerStrategy = new Lazy <ITypeSerializerStrategy>(() => provider.Get(key), true); }
public ContextlessLazyStrategyProvider(IContextualSerializerProvider provider, Type t) { SerializerStrategy = new Lazy <ITypeSerializerStrategy>(() => provider.Get(t), true); }