public static SuperGumpAsset CreateInstance(FileInfo file, bool cache, bool reload) { if (file == null || !file.Exists) { return(Empty); } return(VitaNexCore.TryCatchGet( () => { var hash = CryptoGenerator.GenString(CryptoHashType.MD5, file.FullName); SuperGumpAsset a; lock (_CacheLock) { a = AssetCache.FirstOrDefault(ca => ca.Hash == hash); } if (a == null || reload) { using (var img = new Bitmap(file.FullName, true)) { a = new SuperGumpAsset(file, img); if (cache) { lock (_CacheLock) { AssetCache.AddOrReplace(a); } } } } if (IsNullOrEmpty(a)) { return Empty; } if (!cache || a.Capacity > 0x1000) { lock (_CacheLock) { AssetCache.Remove(a); AssetCache.Free(false); } } lock (_CacheLock) { if (AssetCache.Count > 100) { AssetCache.RemoveAt(0); } AssetCache.Free(false); } return a; }, VitaNexCore.ToConsole)); }