Пример #1
0
        public static void Procedure(RustScript script, string method)
        {
            if (script == null)
            {
                throw new ArgumentNullException(nameof(script));
            }
            if (string.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentNullException(nameof(method));
            }

            Action invoker;

            lock (_procedureCache)
            {
                var target = new InvokeTarget(script, method);
                if (!_procedureCache.TryGetValue(target, out invoker))
                {
                    invoker = InvokeBuilder.GetInvoker <Action>(script, method);
                    _procedureCache.Add(target, invoker);
                }
            }

            invoker?.Invoke();
        }
Пример #2
0
 public byte[] Get(uint crc, Type type, uint entityID, uint numID = 0u)
 {
     using (TimeWarning.New("FileStorage.Get"))
     {
         CacheData value;
         if (_cache.TryGetValue(crc, out value))
         {
             Assert.IsTrue(value.data != null, "FileStorage cache contains a null texture");
             return(value.data);
         }
         if (db == null)
         {
             return(null);
         }
         byte[] array = db.QueryBlob("SELECT data FROM data WHERE crc = ? AND filetype = ? AND entid = ? AND part = ? LIMIT 1", (int)crc, (int)type, (int)entityID, (int)numID);
         if (array == null)
         {
             return(null);
         }
         _cache.Remove(crc);
         _cache.Add(crc, new CacheData
         {
             data     = array,
             entityID = entityID,
             numID    = 0u
         });
         return(array);
     }
 }