public void Init()
    {
      Tracker = new LockTracker("xxx");
      Now = DateTimeOffset.Now.AddHours(2);
      Later = Now.AddHours(4);

      SystemTime.Now = () => Now;
     
    }
    /// <summary>
    /// Gets the resource locks for a given resource from the internal
    /// cache, or creates a new instance if no cached <see cref="LockTracker"/>
    /// instance was found.
    /// </summary>
    /// <param name="resourceId">Identifies the locked resource.</param>
    /// <param name="createIfNotFound">Whether to create and cache a new
    /// <see cref="LockTracker"/> instance if no item is found in the
    /// cache, or just return null.</param>
    /// <returns>A <see cref="LockTracker"/> instance for the requested
    /// resource identifier.</returns>
    private LockTracker GetLocks(string resourceId, bool createIfNotFound)
    {
      LockTracker tracker;
      bool status = lockCache.TryGetValue(resourceId, out tracker);
      if(!status && createIfNotFound)
      {
        tracker = new LockTracker(resourceId);
        lockCache.Add(resourceId, tracker);
      }

      return tracker;
    }
Esempio n. 3
0
        /// <summary>
        /// Gets the resource locks for a given resource from the internal
        /// cache, or creates a new instance if no cached <see cref="LockTracker"/>
        /// instance was found.
        /// </summary>
        /// <param name="resourceId">Identifies the locked resource.</param>
        /// <param name="createIfNotFound">Whether to create and cache a new
        /// <see cref="LockTracker"/> instance if no item is found in the
        /// cache, or just return null.</param>
        /// <returns>A <see cref="LockTracker"/> instance for the requested
        /// resource identifier.</returns>
        private LockTracker GetLocks(string resourceId, bool createIfNotFound)
        {
            LockTracker tracker;
            bool        status = lockCache.TryGetValue(resourceId, out tracker);

            if (!status && createIfNotFound)
            {
                tracker = new LockTracker(resourceId);
                lockCache.Add(resourceId, tracker);
            }

            return(tracker);
        }
 public void Init()
 {
   Tracker = new LockTracker("xxx");
 }