/// <summary>
 /// Initializes a new instance of the <see cref="BackingStoreSerializationWriterProxyFactory"/> class given a concrete implementation of <see cref="ISerializationWriterFactory"/>.
 /// </summary>
 public BackingStoreSerializationWriterProxyFactory(ISerializationWriterFactory concrete) : base(
         concrete,
         (x) => {
     if (x is IBackedModel backedModel && backedModel.BackingStore != null)
     {
         backedModel.BackingStore.ReturnOnlyChangedValues = true;
     }
 /// <summary>
 /// Creates a new proxy factory that wraps the specified concrete factory while composing the before and after callbacks.
 /// </summary>
 /// <param name="concrete">The concrete factory to wrap.</param>
 /// <param name="onBefore">The callback to invoke before the serialization of any model object.</param>
 /// <param name="onAfter">The callback to invoke after the serialization of any model object.</param>
 public SerializationWriterProxyFactory(ISerializationWriterFactory concrete,
                                        Action <IParsable> onBeforeSerialization, Action <IParsable> onAfterSerialization)
 {
     _concrete = concrete ?? throw new ArgumentNullException(nameof(concrete));
     _onBefore = onBeforeSerialization;
     _onAfter  = onAfterSerialization;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpCore"/> class.
 /// <param name="authProvider">The authentication provider.</param>
 /// <param name="pNodeFactory">The parse node factory.</param>
 /// <param name="sWriterFactory">The serialization writer factory.</param>
 /// <param name="client">The native HTTP client.</param>
 /// </summary>
 public HttpCore(IAuthenticationProvider authenticationProvider, IParseNodeFactory parseNodeFactory = null, ISerializationWriterFactory serializationWriterFactory = null, System.Net.Http.HttpClient httpClient = null)
 {
     authProvider   = authenticationProvider ?? throw new ArgumentNullException(nameof(authenticationProvider));
     createdClient  = httpClient == null;
     client         = httpClient ?? new System.Net.Http.HttpClient();
     pNodeFactory   = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance;
     sWriterFactory = serializationWriterFactory ?? SerializationWriterFactoryRegistry.DefaultInstance;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Enables the backing store on default serialization writers and the given serialization writer.
        /// </summary>
        /// <param name="original">The serialization writer to enable the backing store on.</param>
        /// <returns>A new serialization writer with the backing store enabled.</returns>
        public static ISerializationWriterFactory EnableBackingStoreForSerializationWriterFactory(ISerializationWriterFactory original)
        {
            ISerializationWriterFactory result = original ?? throw new ArgumentNullException(nameof(original));

            if (original is SerializationWriterFactoryRegistry registry)
            {
                EnableBackingStoreForSerializationRegistry(registry);
            }
            else
            {
                result = new BackingStoreSerializationWriterProxyFactory(original);
            }
            EnableBackingStoreForSerializationRegistry(SerializationWriterFactoryRegistry.DefaultInstance);
            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Enables the backing store for the registered serialization and parse node factories
 /// </summary>
 public void EnableBackingStore()
 {
     pNodeFactory   = ApiClientBuilder.EnableBackingStoreForParseNodeFactory(pNodeFactory) ?? throw new InvalidOperationException("Could not enable backing store for the parse node factory");
     sWriterFactory = ApiClientBuilder.EnableBackingStoreForSerializationWriterFactory(sWriterFactory) ?? throw new InvalidOperationException("Could not enable backing store for the serializer writer factory");
 }