예제 #1
0
        public static TCast GetItemOfType <TSource, TCast>(this LockList <TSource> lockList) where TCast : Il2CppSystem.Object
            where TSource : Il2CppSystem.Object
        {
            TCast cast   = null;
            var   result = lockList.FirstOrDefault(item => item.IsType(out cast));

            return(cast);

            // Switching to new Linq extension

            /*if (!HasItemsOfType<TSource, TCast>(lockList))
             *  return null;
             *
             * for (int i = 0; i < lockList.Count; i++)
             * {
             *  TSource item = lockList[i];
             *  try
             *  {
             *      if (item.TryCast<TCast>() != null)
             *          return item.TryCast<TCast>();
             *  }
             *  catch (Exception) { }
             * }
             *
             * return null;*/
        }