public ViewsManager(string aConfigFile, IStorageAgent anAgent, IExpressionsManager expressionsManager) { if (String.IsNullOrEmpty(aConfigFile)) { throw new ArgumentNullException("aConfigFile"); } if (null == anAgent) { throw new ArgumentNullException("anAgent"); } if (null == expressionsManager) { throw new ArgumentNullException("expressionsManager"); } configFile = aConfigFile; agent = anAgent; this.ExpressionsManager = expressionsManager; this.Views = new ViewsCollection(this); this.Tables = new TablesCollection(this); this.Relations = new RelationsCollection(this); LoadConfiguration(); }
public NotificationStore() { m_fileAgent = StorageManager.GetGameStorageAgent("notificationStore.json"); m_notificationDict = new Dictionary <int, NotificationState>(); m_orderedNotifications = new List <NotificationState>(); var state = JsonHelper.Deserialize <NotificationState[]>(m_fileAgent); if (state != null) { foreach (var n in state) { // This check is mostly for upgrading from // an older version of the store. if (n.ObjectId != 0) { n.Date = n.Date.ToLocalTime(); m_orderedNotifications.Add(n); m_notificationDict[n.ObjectId] = n; } } } ScriptManager.Instance.ScriptsReset += Instance_ScriptsReset; }
public TaskManager() { AutoAcceptTask = true; m_assignments = new Dictionary <string, AssignmentDriver>(); m_drivers = new Dictionary <string, IPlayerTaskDriver>(); m_outcomeDrivers = new SetDictionary <string, IPlayerTaskDriver>(); ScriptManager.Instance.ScriptsReset += Instance_ScriptsReset; m_completedObjectives = new Dictionary <string, CompleteObjectiveState>(); m_activatedObjectives = new HashSet <string>(); m_fileAgent = StorageManager.GetGameStorageAgent("taskManager.json"); var state = JsonHelper.Deserialize <TaskManagerState>(m_fileAgent); if (state != null) { if (state.CompletedObjectives != null) { foreach (var o in state.CompletedObjectives) { m_completedObjectives[o.Objective.Id] = o; } } if (state.ActivatedObjectives != null) { foreach (var objId in state.ActivatedObjectives) { m_activatedObjectives.Add(objId); } } } }
protected virtual void CreateOrRename(string newkey) { if (string.IsNullOrEmpty(newkey)) { throw new ArgumentNullException("newkey"); } string keyWithPath = this.GetFullPath(this._key); string newkeyWithPath = this.GetFullPath(newkey); if (string.IsNullOrEmpty(this._key)) { if (!Directory.Exists(newkeyWithPath)) { Directory.CreateDirectory(newkeyWithPath); } } else { if (this._key != newkey) { Directory.Move(keyWithPath, newkeyWithPath); } } this._key = newkey; this._agent = new FileAgent(Path.Combine(this.parent, this._key)); }
public ActivatedRecipeManager() { m_recipesByCollectible = new SetDictionary <string, Recipe>(); m_recipesById = new Dictionary <string, Recipe>(); m_fileAgent = StorageManager.GetGameStorageAgent("ActivatedRecipeManager.json"); var state = JsonHelper.Deserialize <ActivatedRecipeStateList>(m_fileAgent); if (state != null && state.Items != null) { foreach (var recInfo in state.Items) { if (recInfo.Recipe == null) { continue; } AddRecipe(recInfo.Recipe); // Check to see if this recipe is in the directory. If it is, use the // item in the directory. Otherwise use the item we saved. var recipe = RecipeDirectory.Instance.GetItem(recInfo.Recipe.Id) ?? recInfo.Recipe; AddRecipe(recipe); } Save(); } ScriptManager.Instance.ScriptsReset += Instance_ScriptsReset; }
public ServiceCacheChip(IDictionary <string, ICacheChip <T> > indexs, string hashKey, StorageFolder folder, DateTime?expTime = null) { this.CachIndexs = indexs; this.HashKey = hashKey; this.Folder = folder; this.ExpirationTime = expTime; _impl = new StorageAgentImpl(); }
public virtual Dictionary <string, List <string> > LoadRoles() { this._agent = RoleManager.Instance.Agent; if (null == this._agent) { throw new InvalidOperationException("Agent not set"); } XmlDocument doc = new XmlDocument(); try { doc.Load(this._agent.OpenStream(this.key)); } finally { this._agent.CloseStream(this.key); } Dictionary <string, List <string> > result = new Dictionary <string, List <string> >(); XmlNode root = doc.SelectSingleNode("roles"); if (null == root) { throw new InvalidOperationException("Roles files has no roles node"); } foreach (XmlNode node in root.ChildNodes) { string name = node.Attributes["name"].Value; if (string.IsNullOrEmpty(name)) { throw new InvalidOperationException(string.Format("Found a role node without a name in '{0}'", this.key)); } if (!result.ContainsKey(name)) { result.Add(name, new List <string>()); } List <string> roleMembers = result[name]; foreach (XmlNode user in node.ChildNodes) { if (null == user.Attributes["name"]) { throw new InvalidOperationException(string.Format("The role '{0}' has a user without name", node.Name)); } if (!roleMembers.Contains(user.Attributes["name"].Value)) { roleMembers.Add(user.Attributes["name"].Value); } } } return(result); }
public ImageCacheChip(IDictionary <string, ICacheChip <BitmapImage> > indexs, string hashKey, StorageFolder folder, DateTime?expTime = null, IProgress <int> progress = null) { this.CachIndexs = indexs; this.HashKey = hashKey; this.Folder = folder; this.ExpirationTime = expTime; _impl = new StorageAgentImpl(); _imageUrl = new Uri(string.Format("ms-appdata:///local/{0}/{1}", Folder.Name, HashKey)); _progress = progress; }
public UsersDataSource(string usersFile, string application) { this._usersFile = usersFile; this.ApplicationName = application; this._agent = new FileAgent(); if (!this._agent.HasKey(usersFile)) { XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateNode(XmlNodeType.XmlDeclaration, "", "")); doc.AppendChild(doc.CreateNode(XmlNodeType.Element, "users", "")); this._agent.Write(this._usersFile, string.Empty); this.SaveUsersFile(doc); } }
public RolesDataSource(string rolesFile, string application) { this._rolesFile = rolesFile; this.ApplicationName = application; this._agent = new FileAgent(); if (!this._agent.HasKey(rolesFile)) { XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateNode(XmlNodeType.XmlDeclaration, "", "")); doc.AppendChild(doc.CreateNode(XmlNodeType.Element, "roles", "")); this._agent.Write(this._rolesFile, string.Empty); this.SaveRolesFile(doc); } }
public ViewsManager(string aConfigFile, IStorageAgent anAgent, IExpressionsManager expressionsManager) { if (String.IsNullOrEmpty(aConfigFile)) throw new ArgumentNullException("aConfigFile"); if (null == anAgent) throw new ArgumentNullException("anAgent"); if (null == expressionsManager) throw new ArgumentNullException("expressionsManager"); configFile = aConfigFile; agent = anAgent; this.ExpressionsManager = expressionsManager; this.Views = new ViewsCollection(this); this.Tables = new TablesCollection(this); this.Relations = new RelationsCollection(this); LoadConfiguration(); }
public Inventory() { m_inventoryItems = new Dictionary <string, InventoryItemState>(); m_fileAgent = StorageManager.GetGameStorageAgent("inventory.json"); var state = JsonHelper.Deserialize <InventoryState>(m_fileAgent); if (state != null && state.Items != null) { foreach (var cc in state.Items) { m_inventoryItems[cc.CollectibleId] = cc; } } ScriptManager.Instance.ScriptsReset += Instance_ScriptsReset; }
public static async Task Main(string[] args) { IConfigurationRoot configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false, true) .Build(); IHost host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { IServiceProvider services = scope.ServiceProvider; ILogger <Program> logger = services.GetRequiredService <ILogger <Program> >(); try { logger.LogInformation("Press x to cancel StorageAgent task"); var tokenSource = new CancellationTokenSource(); var cancellationToken = tokenSource.Token; IStorageAgent storageAgent = services.GetRequiredService <IStorageAgent>(); //await storageAgent.CleanupDatabase(cancellationToken); await Task.Run(() => { Task <Task> task = storageAgent.CleanupDatabase(cancellationToken); while (!task.IsCompleted) { if (Console.ReadKey().Key == ConsoleKey.X) { tokenSource.Cancel(); logger.LogWarning("x key pressed, Operation Cancelled."); break; } } return(Task.CompletedTask); }, cancellationToken); } catch (Exception ex) { logger.LogCritical("Error executing/completeing Storage Agent Service" + ex); //Log.CloseAndFlush(); //await host.StopAsync(); } } host.Run(); }
public Wallet() { m_stateFile = StorageManager.GetGameFileName("wallet.json"); m_fileAgent = (Platform.Instance.UseEncryption) ? new EncryptedFileStorageManager(Application.persistentDataPath).GetAgent(m_stateFile) : new FileStorageManager(Application.persistentDataPath).GetAgent(m_stateFile); m_itemDict = new Dictionary <string, WalletCurrencyItem>(); var state = JsonHelper.Deserialize <WalletCurrencyState>(m_fileAgent); if (state != null && state.Currencies != null) { foreach (var wis in state.Currencies) { m_itemDict[wis.CurrencyName] = wis; } } ScriptManager.Instance.ScriptsReset += Instance_ScriptsReset; }
public virtual Dictionary <string, Dictionary <string, List <string> > > LoadAcces() { this._agent = SiteAccessVerifier.Instance.Agent; if (null == this._agent) { throw new InvalidOperationException("Agent not set"); } XmlDocument doc = new XmlDocument(); try { doc.Load(this._agent.OpenStream(this.key)); } finally { this._agent.CloseStream(this.key); } Dictionary <string, Dictionary <string, List <string> > > access = new Dictionary <string, Dictionary <string, List <string> > >(); XmlNode root = doc.SelectSingleNode("access"); if (null == root) { throw new InvalidOperationException("Access file has no access node"); } foreach (XmlNode appNode in root.ChildNodes) { if ("app" != appNode.Name) { throw new InvalidOperationException(String.Format("expected app but found '{0}' in '{1}'", appNode.Name, key)); } string app = appNode.Attributes["key"].Value; if (!access.ContainsKey(app)) { access.Add(app, new Dictionary <string, List <string> >()); } foreach (XmlNode screenNode in appNode.ChildNodes) { if ("screen" != screenNode.Name) { throw new InvalidOperationException(String.Format("expected screen but found '{0}' in app '{1}' in '{2}'", screenNode.Name, app, key)); } string screen = screenNode.Attributes["key"].Value; if (!access[app].ContainsKey(screen)) { access[app].Add(screen, new List <string>()); } List <string> screenMembers = access[app][screen]; foreach (XmlNode role in screenNode.ChildNodes) { if ("role" != role.Name) { throw new InvalidOperationException(String.Format("expected role but found '{0}' in screen '{1}' in app '{2}' in '{3}'", role.Name, screen, app, key)); } if (!screenMembers.Contains(role.Attributes["name"].Value)) { screenMembers.Add(role.Attributes["name"].Value); } } } } return(access); }
public StorageAgentLogDecorator(IStorageAgent storageAgent) { _storageAgent = storageAgent; }
public StorageAgentDurationDecorator(IStorageAgent storageAgent) { _storageAgent = storageAgent; }
public DirectoryContainer() { this.parent = string.Empty; this._key = string.Empty; this._agent = new FileAgent(); }
public ScreensRoutingAgent() { this.Agent = new FileAgent(); }
public ScriptRunnerManager() { m_runningItems = new List <ScriptDirectoryItem>(); m_storageAgent = StorageManager.GetGameStorageAgent("runningScripts.json"); }
public Database(string name, string viewsKey, IStorageAgent agent, IExpressionsManager expressionsManager) { this.Name = name; this.ViewsKey = viewsKey; this.ViewsManager = new ViewsManager(viewsKey, agent, expressionsManager); }
public virtual Dictionary<string, List<string>> LoadAcces() { this._agent = AccessVerifier.Instance.Agent; if (null == this._agent) { throw new InvalidOperationException("Agent not set"); } XmlDocument doc = new XmlDocument(); try { doc.Load(this._agent.OpenStream(this.key)); } finally { this._agent.CloseStream(this.key); } Dictionary<string, List<string>> result = new Dictionary<string, List<string>>(); XmlNode root = doc.SelectSingleNode("access"); if (null == root) throw new InvalidOperationException("Access file has no access node"); foreach (XmlNode node in root.ChildNodes) { string name = node.Attributes["key"].Value; if (string.IsNullOrEmpty(name)) throw new InvalidOperationException(string.Format("Found a screen node without a key in '{0}'", this.key)); if (!result.ContainsKey(name)) result.Add(name, new List<string>()); List<string> screenMembers = result[name]; foreach (XmlNode role in node.ChildNodes) { if (null == role.Attributes["name"]) throw new InvalidOperationException(string.Format("The screen '{0}' has a role without name", node.Name)); if (!screenMembers.Contains(role.Attributes["name"].Value)) screenMembers.Add(role.Attributes["name"].Value); } } return result; }
public EmployeeSolution(IStorageAgent persistanceStorageAgent) { //Assigning the injected dependency to local reference. persistanceStorageDependency = persistanceStorageAgent; }
public virtual Dictionary<string, Dictionary<string, List<string>>> LoadAcces() { this._agent = SiteAccessVerifier.Instance.Agent; if (null == this._agent) throw new InvalidOperationException("Agent not set"); XmlDocument doc = new XmlDocument(); try { doc.Load(this._agent.OpenStream(this.key)); } finally { this._agent.CloseStream(this.key); } Dictionary<string, Dictionary<string, List<string>>> access = new Dictionary<string, Dictionary<string, List<string>>>(); XmlNode root = doc.SelectSingleNode("access"); if (null == root) throw new InvalidOperationException("Access file has no access node"); foreach (XmlNode appNode in root.ChildNodes) { if ("app" != appNode.Name) throw new InvalidOperationException(String.Format("expected app but found '{0}' in '{1}'", appNode.Name, key)); string app = appNode.Attributes["key"].Value; if (!access.ContainsKey(app)) access.Add(app, new Dictionary<string, List<string>>()); foreach (XmlNode screenNode in appNode.ChildNodes) { if ("screen" != screenNode.Name) throw new InvalidOperationException(String.Format("expected screen but found '{0}' in app '{1}' in '{2}'", screenNode.Name, app, key)); string screen = screenNode.Attributes["key"].Value; if (!access[app].ContainsKey(screen)) access[app].Add(screen, new List<string>()); List<string> screenMembers = access[app][screen]; foreach (XmlNode role in screenNode.ChildNodes) { if ("role" != role.Name) throw new InvalidOperationException(String.Format("expected role but found '{0}' in screen '{1}' in app '{2}' in '{3}'", role.Name, screen, app, key)); if (!screenMembers.Contains(role.Attributes["name"].Value)) { screenMembers.Add(role.Attributes["name"].Value); } } } } return access; }