/// <summary> /// Create a Resilient Managed Database. /// </summary> /// <param name="database"> /// A <see cref="IManagedBrowsingDatabase" /> to proxy to. /// </param> /// <param name="retryAttempts"> /// The number of attempts a failed operation should be retried. /// </param> /// <param name="ownDatabase"> /// A boolean flag indicating whether or not the resilient managed database takes ownership of /// <paramref name="database" /> and disposes it when the resilient managed database itself is disposed. If /// the resilient managed database takes ownership of <paramref name="database" /> and you reference or /// dispose <paramref name="database" /> after you create the resilient managed database, the behavior of /// the resilient managed database and <paramref name="database" /> is undefined. /// </param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="database" /> is a null reference. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// Thrown if <paramref name="retryAttempts" /> is less than or equal to <c>0</c>. /// </exception> public ResilientManagedBrowsingDatabase(IManagedBrowsingDatabase database, int retryAttempts, bool ownDatabase) : base(retryAttempts) { Guard.ThrowIf(nameof(retryAttempts), retryAttempts).LessThanOrEqualTo(0); this._database = ManagedBrowsingDatabaseProxy.Create(database, ownDatabase); this._disposed = false; this._ownDatabase = ownDatabase; }
/// <summary> /// Create a Managed Database Proxy. /// </summary> /// <param name="database"> /// A <see cref="IManagedBrowsingDatabase" /> to proxy to. The managed database proxy takes ownership of /// <paramref name="database" /> and will dispose it when the managed database proxy itself is disposed. If /// you reference or dispose <paramref name="database" /> after you create the managed database proxy, the /// behavior of the managed database proxy and <paramref name="database" /> is undefined. /// </param> /// <returns> /// A managed database proxy. /// </returns> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="database" /> is a null reference. /// </exception> internal static ManagedBrowsingDatabaseProxy Create(IManagedBrowsingDatabase database) => ManagedBrowsingDatabaseProxy.Create(database, true);