Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LockToken" /> class with the specified lock timeouts.
        /// </summary>
        /// <param name="key">The key representing the resource to lock.</param>
        /// <param name="timeouts">The <see cref="LockTimeoutData" /> that defines timeout behavior.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="key" /> is null.
        /// <para>or</para>
        /// <paramref name="timeouts" /> is null.
        /// </exception>
        /// <exception cref="ArgumentException"><paramref name="key" /> is an empty string.</exception>
        internal LockToken(string key, LockTimeoutData timeouts)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (timeouts == null)
            {
                throw new ArgumentNullException(nameof(timeouts));
            }

            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Key cannot be an empty string.", nameof(key));
            }

            Key            = key;
            AcquireTimeout = timeouts.AcquireTimeout;
            HoldTimeout    = timeouts.HoldTimeout;
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetLockToken" /> class with the specified lock timeouts.
 /// </summary>
 /// <param name="asset">The <see cref="IAssetInfo" /> representing the asset to lock.</param>
 /// <param name="timeouts">The <see cref="LockTimeoutData" /> that defines timeout behavior.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="asset" /> is null.
 /// <para>or</para>
 /// <paramref name="timeouts" /> is null.
 /// </exception>
 /// <exception cref="ArgumentException"><paramref name="asset" /> ID is an empty string.</exception>
 public AssetLockToken(IAssetInfo asset, LockTimeoutData timeouts)
     : base(GetKey(asset), timeouts)
 {
     AssetInfo = asset;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalLockToken" /> class with the specified lock timeouts.
 /// </summary>
 /// <param name="key">The key representing the resource to lock.</param>
 /// <param name="timeouts">The <see cref="LockTimeoutData" /> that defines timeout behavior.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="key" /> is null.
 /// <para>or</para>
 /// <paramref name="timeouts" /> is null.
 /// </exception>
 /// <exception cref="ArgumentException"><paramref name="key" /> is an empty string.</exception>
 public GlobalLockToken(string key, LockTimeoutData timeouts)
     : base(key, timeouts)
 {
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalLockToken" /> class with the specified lock timeouts.
 /// </summary>
 /// <param name="key">The key representing the resource to lock.</param>
 /// <param name="timeouts">The <see cref="LockTimeoutData" /> that defines timeout behavior.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="key" /> is null.
 /// <para>or</para>
 /// <paramref name="timeouts" /> is null.
 /// </exception>
 /// <exception cref="ArgumentException"><paramref name="key" /> is an empty string.</exception>
 public LocalLockToken(string key, LockTimeoutData timeouts)
     : base(CreateLocalKey(key), timeouts)
 {
 }