Example #1
0
 /// <summary>
 ///     Get the index for the type
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns>The type</returns>
 public virtual int GetTypeIndex(string type)
 {
     lock (((ICollection)TypeIndex).SyncRoot)
     {
         if (!TypeIndex.Contains(type))
         {
             TypeIndex.Add(type);
         }
         return(TypeIndex.IndexOf(type));
     }
 }
        /// <summary>
        ///     Get the index for the type
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>The type</returns>
        public override async Task <int> GetTypeIndexAsync(string type)
        {
            using (await _lock.LockAsync().ConfigureAwait(false))
            {
                if (!TypeIndex.Contains(type))
                {
                    TypeIndex.Add(type);
                    _dirtyType = true;
                }
            }

            return(TypeIndex.IndexOf(type));
        }
Example #3
0
 /// <summary>
 ///     Get the index for the type
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns>The type</returns>
 public virtual Task <int> GetTypeIndexAsync(string type)
 {
     return(Task.Factory.StartNew(() =>
     {
         lock (((ICollection)TypeIndex).SyncRoot)
         {
             if (!TypeIndex.Contains(type))
             {
                 TypeIndex.Add(type);
             }
             return TypeIndex.IndexOf(type);
         }
     }));
 }
Example #4
0
        public override async Task <int> GetTypeIndexAsync(string type)
        {
            var pathLock = Lock.GetLock(TypeIndex.GetType().FullName);

            using (await pathLock.LockAsync().ConfigureAwait(false))
            {
                if (!TypeIndex.Contains(type))
                {
                    TypeIndex.Add(type);
                    _dirtyType = true;
                }

                return(TypeIndex.IndexOf(type));
            }
        }
Example #5
0
 /// <summary>
 ///     Get the index for the type
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns>The type</returns>
 public override Task <int> GetTypeIndexAsync(string type)
 {
     return(Task.Factory.StartNew(() =>
     {
         var pathLock = PathLock.GetLock(TypeIndex.GetType().FullName);
         lock ( pathLock )
         {
             if (!TypeIndex.Contains(type))
             {
                 TypeIndex.Add(type);
                 _dirtyType = true;
             }
         }
         return TypeIndex.IndexOf(type);
     }, TaskCreationOptions.AttachedToParent));
 }