public PopupPlayers(IAnimaManager animaManager, IObjectStorage objectStorage, IPublisher publisher, IConfigurateManager configurateManager) { _animaManager = animaManager; _objectStorage = objectStorage; _publisher = publisher; _configurateManager = configurateManager; _dictionaryPoints = new Dictionary <GameClass, List <float> >(); //points = xmin, ymax, ymin, ymax _dictionaryPoints[GameClass.Red] = new List <float>() { 0.124f, 0.888f, 0.761f, 0.985f }; _dictionaryPoints[GameClass.Green] = new List <float>() { 0.124f, 0.888f, 0.511f, 0.744f }; _dictionaryPoints[GameClass.Blue] = new List <float>() { 0.124f, 0.888f, 0.259f, 0.492f }; _dictionaryPoints[GameClass.Purple] = new List <float>() { 0.124f, 0.888f, 0.0154f, 0.2405f }; }
public static bool IncrementAttempts(this IObjectStorage storage, ObjectInfo info) { string[] parts = info.Path.Split('.'); if (parts.Length < 3) { throw new ArgumentException(String.Format("Path \"{0}\" must contain the number of attempts.", info.Path)); } int version; if (!Int32.TryParse(parts[1], out version)) { throw new ArgumentException(String.Format("Path \"{0}\" must contain the number of attempts.", info.Path)); } version++; string newpath = String.Join(".", parts[0], version, parts[2]); if (parts.Length == 4) { newpath += "." + parts[3]; } string originalPath = info.Path; info.Path = newpath; return(storage.RenameObject(originalPath, newpath)); }
public static void DeleteFiles(this IObjectStorage storage, IEnumerable <ObjectInfo> files) { foreach (var file in files) { storage.DeleteObject(file.Path); } }
public void CanManageFiles() { Reset(); IObjectStorage storage = GetStorage(); storage.SaveObject("test.txt", "test"); Assert.Equal(1, storage.GetObjectList("test.txt").Count()); Assert.Equal(1, storage.GetObjectList().Count()); var file = storage.GetObjectList().FirstOrDefault(); Assert.NotNull(file); Assert.Equal("test.txt", file.Path); string content = storage.GetObject <string>("test.txt"); Assert.Equal("test", content); storage.RenameObject("test.txt", "new.txt"); Assert.True(storage.GetObjectList().Any(f => f.Path == "new.txt")); storage.DeleteObject("new.txt"); Assert.Equal(0, storage.GetObjectList().Count()); storage.SaveObject("test\\q\\" + Guid.NewGuid().ToString("N") + ".txt", "test"); Assert.Equal(1, storage.GetObjectList("test\\q\\*.txt").Count()); Assert.Equal(1, storage.GetObjectList("*", null, DateTime.Now).Count()); List <ObjectInfo> files = storage.GetObjectList("*", null, DateTime.Now.Subtract(TimeSpan.FromMinutes(5))).ToList(); Debug.WriteLine(String.Join(",", files.Select(f => f.Path + " " + f.Created))); Assert.Equal(0, files.Count); }
public PersistedDictionary(string path, IObjectStorage objectStorage, IJsonSerializer serializer, int delay = 250) { _objectStorage = objectStorage; _path = path; _delay = delay; Changed += OnChanged; _timer = new Timer(OnSaveTimer, null, -1, -1); }
public static void ReleaseBatch(this IObjectStorage storage, IList <Tuple <ObjectInfo, Event> > batch) { foreach (var item in batch) { storage.ReleaseFile(item.Item1); } }
public static IList <Tuple <ObjectInfo, Event> > GetEventBatch(this IObjectStorage storage, string queueName, IJsonSerializer serializer, int batchSize = 50, DateTime?maxCreatedDate = null) { var events = new List <Tuple <ObjectInfo, Event> >(); lock (_lockObject) { foreach (var file in storage.GetQueueFiles(queueName, batchSize * 5, maxCreatedDate)) { if (!storage.LockFile(file)) { continue; } try { storage.IncrementAttempts(file); } catch {} try { var ev = storage.GetObject <Event>(file.Path); events.Add(Tuple.Create(file, ev)); if (events.Count == batchSize) { break; } } catch {} } return(events); } }
public LevelManager(IUpdateManager updateManager, IObjectStorage objectStorage) { _updateManager = updateManager; _objectStorage = objectStorage; _updateManager.AddUpdatable(this); }
public static void DeleteBatch(this IObjectStorage storage, IList <Tuple <ObjectInfo, Event> > batch) { foreach (var item in batch) { storage.DeleteObject(item.Item1.Path); } }
private DataStorageInterceptor(IObjectStorage storage) { this.storage = storage; setters = typeof(T).GetProperties().ToDictionary(p => p.GetSetMethod()); getters = typeof(T).GetProperties().ToDictionary(p => p.GetGetMethod()); }
public UserService(IAppDbContext dbContext, UserManager <User> userManager, IUserContext userContext, IObjectStorage objectStorage) { this.dbContext = dbContext; this.userManager = userManager; this.userContext = userContext; this.objectStorage = objectStorage; }
/// <summary> /// TODO:IDEA: the intercepter can be shared for improved performance! /// </summary> /// <param name="storage"></param> /// <param name="generator"></param> /// <returns></returns> public static T ImplementInterface(IObjectStorage storage, ProxyGenerator generator) { var interceptor = new DataStorageInterceptor <T>(storage); var proxy = (T)generator.CreateInterfaceProxyWithoutTarget(typeof(T), interceptor); return(proxy); }
/// <summary>执行与释放或重置非托管资源关联的应用程序定义的任务。</summary> /// <filterpriority>2</filterpriority> public void Dispose() { if (_objectStorage != null) { _objectStorage.Dispose(); _objectStorage = null; } }
public static async Task <T> Get <T>(this IObjectStorage reader, string fileName, Func <Stream, T> readerFn, CancellationToken cancellationToken = default) { var tsc = new TaskCompletionSource <T>(); var readerFnProxy = act((Stream s) => { tsc.SetResult(readerFn(s)); }); await reader.Get(fileName, readerFnProxy, cancellationToken); return(await tsc.Task); }
public PopupGameMenu(IObjectStorage objectStorage, IPublisher publisher, IAnimaManager animaManager, ICoroutiner coroutiner) { _objectStorage = objectStorage; _publisher = publisher; _animaManager = animaManager; _coroutiner = coroutiner; }
public PlatformManager(IUpdateManager updateManager, IObjectStorage objectStorage) { _objectStorage = objectStorage; _updateManager = updateManager; _updateManager.AddUpdatable(this); _slowPlatform = Constants.countSlowPlatform; }
public GetPropertyMessageHandler( IMessageConstructor messageConstructor, IClientLookup clientLookup, IObjectStorage objectStorage) { this.m_MessageConstructor = messageConstructor; this.m_ClientLookup = clientLookup; this.m_ObjectStorage = objectStorage; }
public TokenRewardManager(IPublisher publisher, IAnimaManager animaManager, IObjectStorage objectStorage, IConfigurateManager configurateManager) { _publisher = publisher; _animaManager = animaManager; _objectStorage = objectStorage; _configurateManager = configurateManager; _dictionaryIconToken = new Dictionary <GameClass, List <GameObject> >(); _dictionaryToken = new Dictionary <GameClass, List <TokenRewardEnum> >(); }
public PopupEvent(IObjectStorage objectStorage, IPublisher publisher, IAnimaManager animaManager, ICoroutiner coroutiner, IConfigurateManager configurateManager) { _objectStorage = objectStorage; _publisher = publisher; _animaManager = animaManager; _coroutiner = coroutiner; _configurateManager = configurateManager; }
public FetchResultMessageHandler( IMessageSideChannel messageSideChannel, IObjectStorage objectLookup, IObjectWithTypeSerializer objectWithTypeSerializer) { this.m_MessageSideChannel = messageSideChannel; this.m_ObjectLookup = objectLookup; this.m_ObjectWithTypeSerializer = objectWithTypeSerializer; }
public EnemyManager(IPublisher publisher, ICoroutiner coroutiner, IAnimaManager animaManager, IObjectStorage objectStorage, IConfigurateManager configurateManager) { _publisher = publisher; _coroutiner = coroutiner; _animaManager = animaManager; _objectStorage = objectStorage; _configurateManager = configurateManager; _listEnemys = new List <GameObject>(); }
private static string SaveObjectToStorage(object tree, IObjectStorage storage) { var jsonRepresentation = JsonConvert.SerializeObject(tree, Formatting.Indented); var bytes = Encoding.UTF8.GetBytes(jsonRepresentation); string hashString = Hash(bytes); storage.Set(hashString, new MemoryStream(bytes)); return(hashString); }
public AudioManager(IObjectStorage objectStorage, ICoroutiner coroutiner) { _objectStorage = objectStorage; _coroutiner = coroutiner; _lowPitchRange = 0.95f; _highPitchRange = 1.05f; _crossFadeRate = 1.5f; _musicVolume = 0.3f; }
public static async Task PutString(this IObjectStorage reader, string fileName, string value, string mimeType, CancellationToken cancellationToken = default) { await reader.Put(fileName, stream => { using (var writer = new StreamWriter(stream)) { writer.Write(value); } }, mimeType, cancellationToken); }
public GameManager(IPublisher publisher, IAnimaManager animaManager, IObjectStorage objectStorage, ICoroutiner coroutiner, IInventoryManager inventoryManager, IConfigurateManager configurateManager) { _publisher = publisher; _animaManager = animaManager; _objectStorage = objectStorage; _coroutiner = coroutiner; _inventoryManager = inventoryManager; _configurateManager = configurateManager; }
public MasterManager(ICoroutiner coroutiner, IUpdateManager updateManager, INotifier gameplayNotifier, INotifier uiNotifier, IObjectStorage objectStorage, ISpawnManager spawnManager) { Coroutiner = coroutiner; UpdateManager = updateManager; GameplayNotifier = gameplayNotifier; UINotifier = uiNotifier; ObjectStorage = objectStorage; SpawnManager = spawnManager; }
public PopupRewardEvent(IPublisher publisher, IObjectStorage objectStorage, IConfigurateManager configurateManager, ICoroutiner coroutiner) { _publisher = publisher; _objectStorage = objectStorage; _configurateManager = configurateManager; _coroutiner = coroutiner; //_emptyTokens = new List<TokenRewardEnum>(){TokenRewardEnum.Pass, TokenRewardEnum.RestoreHealth}; _tokensReward = new List <TokenRewardEnum>(); //_rectTokensReward = new List<float>(){0.3435f,0.4242f,0.7052f,0.574f}; }
public DefaultEventQueue(ExceptionlessConfiguration config, IExceptionlessLog log, ISubmissionClient client, IObjectStorage objectStorage, IJsonSerializer serializer, TimeSpan? processQueueInterval, TimeSpan? queueStartDelay) { _log = log; _config = config; _client = client; _storage = objectStorage; _serializer = serializer; if (processQueueInterval.HasValue) _processQueueInterval = processQueueInterval.Value; _queueTimer = new Timer(OnProcessQueue, null, queueStartDelay ?? TimeSpan.FromSeconds(2), _processQueueInterval); }
public static async Task <T> GetJSON <T>(this IObjectStorage reader, string fileName, CancellationToken cancellationToken = default) { return(await reader.Get(fileName, stream => { using (var sr = new StreamReader(stream)) using (var jsonReader = new JsonTextReader(sr)) { return JToken.Load(jsonReader).ToObject <T>(); } }, cancellationToken)); }
public FetchMessageHandler( IObjectStorage lookup, IMessageConstructor messageConstructor, IClientLookup clientLookup, IObjectWithTypeSerializer objectWithTypeSerializer) { this.m_Lookup = lookup; this.m_MessageConstructor = messageConstructor; this.m_ClientLookup = clientLookup; this.m_ObjectWithTypeSerializer = objectWithTypeSerializer; }
public static async Task PutJSON <T>(this IObjectStorage reader, string fileName, T value, CancellationToken cancellationToken = default) { await reader.Put(fileName, stream => { using (var sr = new StreamWriter(stream)) using (var jsonWriter = new JsonTextWriter(sr)) { JToken.FromObject(value).WriteTo(jsonWriter); } }, "application/json", cancellationToken); }
public DefaultObjectLookup( ILocalNode localNode, IObjectStorage objectStorage, IClientLookup clientLookup, IMessageConstructor messageConstructor, IMessageSideChannel messageSideChannel) { this.m_LocalNode = localNode; this.m_ObjectStorage = objectStorage; this.m_ClientLookup = clientLookup; this.m_MessageConstructor = messageConstructor; this.m_MessageSideChannel = messageSideChannel; }
public SetPropertyMessageHandler( ILocalNode localNode, IObjectStorage objectStorage, IObjectWithTypeSerializer objectWithTypeSerializer, IMessageConstructor messageConstructor, IClientLookup clientLookup) { this.m_LocalNode = localNode; this.m_ObjectStorage = objectStorage; this.m_ObjectWithTypeSerializer = objectWithTypeSerializer; this.m_MessageConstructor = messageConstructor; this.m_ClientLookup = clientLookup; }
public ObjectStorageBasedShoppingCarts(IObjectStorage storage) { this.storage = storage; }
public DefaultEventQueue(ExceptionlessConfiguration config, IExceptionlessLog log, ISubmissionClient client, IObjectStorage objectStorage, IJsonSerializer serializer): this(config, log, client, objectStorage, serializer, null, null) {}