public void ExecuteSucceedsWithAttributeUpdate() { var command = new ElementInsertionCommand( "/configuration", new ElementSpecification( "test", null, new[] { new AttributeSpecification { Name = "test", NamespaceUri = "urn:test", Value = "value" }, new AttributeSpecification { Name = "test", Value = "value" } }, "test")); var document = Files.Load("web-original.config").AsXmlDocument(); command.Execute(document); document.SelectSingleNode("/configuration/test") .Should().NotBeNull(); document.SelectSingleNode("/configuration/test/@*[local-name() = 'test' and namespace-uri()='urn:test']") .Should().NotBeNull() .And.Subject.Value.Should().Be("value"); document.SelectSingleNode("/configuration/test/@test") .Should().NotBeNull() .And.Subject.Value.Should().Be("value"); }
public void ChangeType() { CaseStatus files = Files.Load().GetCaseStatus(); if (type == SelectionType.NONE) { if (files.clues.Count > 0) { type = SelectionType.CLUE; clue = files.clues[0]; } else if (files.witnesses.Count > 0) { type = SelectionType.WITNESS; witness = files.witnesses[0]; } } else if (type == SelectionType.CLUE) { if (files.witnesses.Count > 0) { type = SelectionType.WITNESS; witness = files.witnesses[0]; } else { type = SelectionType.NONE; } } else if (type == SelectionType.WITNESS) { type = SelectionType.NONE; } }
public void SetObject(WitnessData witness) { CaseData openedCase = InvestigationManager.GetCase(); GetComponent <CanvasGroup>().alpha = 1; string fullDescription = ""; fullDescription += "IDADE: " + witness.age + "\n"; fullDescription += "PROFISSÃO: " + witness.job + "\n"; fullDescription += "RUMORES:"; Files files = Files.Load(); int witnessIndex = openedCase.GetWitnessIndexFromData(witness); foreach (Rumor r in files.GetCaseStatus().rumors) { if (r.target == witnessIndex) { RumorData rd = openedCase.GetRumorData(r); print(r.from + "/" + r.target); fullDescription += "\n" + "* " + rd.from.witnessName + ": " + rd.description; } } description.text = fullDescription; title.text = witness.witnessName; icon.sprite = witness.image; }
public void ListAllCollectedClues(ClueSpaceUI caller) { CaseData openedCase = InvestigationManager.GetCase(); Open(); Erase(); Files files = Files.Load(); this.caller = caller; var l = files.GetCaseStatus().clues; for (int i = 0; i < l.Count; i++) { var clue = l[i]; ClueData cd = openedCase.GetClueData(clue); var go = Instantiate(cluePrefab, root); go.GetComponent <ClueForListUI>().SetInfo(cd); go.GetComponent <Button>().onClick.AddListener( delegate { ClueData c = cd; Choose(c); }); if (i == 0) { go.GetComponent <Button>().Select(); } } }
private ConfigurationPage() { InitializeComponent(); var config = Files.Load <Configuration>(Files.Paths.ConfigXml); this.SetConfiguration(config); }
public void BuildCurrentNodePathSucceedsWithoutDiscriminants() { new XPathBuilder( Files.Load("create-node-change-with-discriminant.config") .AsXPathNavigator() .SelectSingleNode("/configuration/system.net/connectionManagement")) .BuildCurrentNodePath().Should().Be("*[local-name()='connectionManagement']"); }
private void AddToManager(IBlog blog) { QueueOnDispatcher.CheckBeginInvokeOnUI(() => _managerService.BlogFiles.Add(blog)); if (_shellService.Settings.LoadAllDatabases) { _managerService.AddDatabase(Files.Load(blog.ChildId)); } }
public bool ChangeCollection(IBlog blog, Collection oldItem, Collection newItem) { if (oldItem == null || newItem == null) { return(false); } if (QueueManager.Items.Any(x => x.Blog.Name == blog.Name && x.Blog.OriginalBlogType == blog.OriginalBlogType)) { _messageService.ShowWarning(Resources.CannotChangeCollectionOfQueuedBlog); return(false); } var oldFilenameIndex = Path.Combine(blog.Location, blog.Name) + "." + blog.OriginalBlogType; var oldFilenameChild = blog.ChildId; var newRootFolder = Path.Combine(newItem.DownloadLocation, "Index"); var newFilenameIndex = Path.Combine(newRootFolder, blog.Name) + "." + blog.OriginalBlogType; var newFilenameChild = Path.Combine(newRootFolder, Path.GetFileName(oldFilenameChild)); Directory.CreateDirectory(newRootFolder); if (File.Exists(newFilenameIndex) || File.Exists(newFilenameChild)) { _messageService.ShowWarning(Resources.CannotChangeCollectionDestFileExists); return(false); } blog.CollectionId = newItem.Id; blog.Location = newRootFolder; blog.FileDownloadLocation = null; blog.ChildId = newFilenameChild; blog.Save(); File.Delete(oldFilenameIndex); File.Move(oldFilenameChild, newFilenameChild); _managerService.BlogFiles.Remove(blog); _managerService.EnsureUniqueFolder(blog); if (blog.Dirty) { blog.Save(); } if (_shellService.Settings.LoadAllDatabases) { _managerService.RemoveDatabase(_managerService.Databases.FirstOrDefault(db => db.Name.Equals(blog.Name) && db.BlogType.Equals(blog.OriginalBlogType))); } _managerService.BlogFiles.Add(blog); if (_shellService.Settings.LoadAllDatabases) { _managerService.AddDatabase(Files.Load(blog.ChildId)); } return(true); }
public void Introduce() { CaseData openedCase = InvestigationManager.GetCase(); Files files = Files.Load(); bool added = files.GetCaseStatus().AddWitness(openedCase.GetWitnessIndexFromData(data)); files.Save(); DialogUI.StartDialog(data.introducingDialog, added, DialogType.WITNESS); }
public void ExecuteThrowsWhenElementAlreadyExists() { var command = new ElementInsertionCommand( "/configuration", new ElementSpecification("appSettings", null, null, "appSettings")); Action act = () => command.Execute(Files.Load("web-original.config").AsXmlDocument()); act.Should().ThrowExactly <InvalidOperationException>() .WithMessage("The configuration element already exists at '/configuration/appSettings'."); }
private ObservableCollection <LogsModel> logs; //Коллекция логов #endregion #region Constructors /// <summary> /// Конструктор для инициализации данных /// </summary> public LogsViewModel() { logs = new ObservableCollection <LogsModel>(); Files files = new Files(); if (files.Load(Properties.Settings.Default.PathFileLogs, Logs)) { Logs = (ObservableCollection <LogsModel>)files.DataLoad; } }
public void BuildAbsolutePathSucceedsWithDiscriminants() { new XPathBuilder( Files.Load("create-node-change-with-discriminant.config") .AsXPathNavigator() .SelectSingleNode("/configuration/system.net/connectionManagement/add")) .BuildAbsolutePath().Should() .Be( "/*[local-name()='configuration']/*[local-name()='system.net']/*[local-name()='connectionManagement']/*[local-name()='add' and (@address = '*')]"); }
private IFiles LoadFiles(IBlog blog) { if (settings.LoadAllDatabases) { return(managerService.Databases.FirstOrDefault(file => file.Name.Equals(blog.Name) && file.BlogType.Equals(blog.BlogType))); } return(Files.Load(blog.ChildId)); }
public void Investigate() { CaseData openedCase = InvestigationManager.GetCase(); Files files = Files.Load(); bool added = files.GetCaseStatus().AddClue(openedCase.clues.IndexOf(clueData)); files.Save(); DialogUI.StartDialog(clueData.findingDialog, added, DialogType.CLUE); }
public void CreateFailedWhenActionIsMissing() { Action act = () => { ConfigurationCommandFactory.Create( Files.Load("create-node-change.config") .AsXPathNavigator() .SelectSingleNode("/configuration")); }; act.Should().ThrowExactly <InvalidOperationException>(); }
protected void FoundCase(CaseData caseData) { int caseIndex = InvestigationManager.me.storage.cases.IndexOf(caseData); InvestigationManager.SetCase(caseIndex); Files files = Files.Load(); files.SetInitialClues(caseData.initialClues, caseIndex); files.Save(); DialogUI.StartDialog(caseData.findingDialog, InvestigationManager.me.currentCase != caseIndex, DialogType.CASE); }
public void ExecuteSucceeds() { var command = new ElementInsertionCommand( "/configuration", new ElementSpecification("test", null, null, "test")); var document = Files.Load("web-original.config").AsXmlDocument(); command.Execute(document); document.SelectSingleNode("/configuration/test") .Should().NotBeNull(); }
public TestPage() { InitializeComponent(); config = Files.Load <Configuration>(Files.Paths.ConfigXml); if (config == null) { config = new Configuration(); } }
public async Task UpdateOrder(string newStatus, long idOrder) { var config = Files.Load <Configuration>(Files.Paths.ConfigXml); string username = config.WordpressUsername; string password = config.WordpressPassword; string url = $"{config.WordpressUrl}/index.php/wp-json/wc/v2/orders/{idOrder}"; string payload = JsonConvert.SerializeObject(new { status = newStatus }); await WordPress.Put(username, password, url, payload); }
public void CreateSucceedsForElementDeletionChange() { ConfigurationCommandFactory.Create( Files .Load("delete-element-command.config") .AsXPathNavigator() .SelectSingleNode("/configuration/appSettings/add[@key='second_setting']")) .Should().NotBeNull() .And.BeOfType <ElementDeletionCommand>() .Which.ConfigurationElementSelector .Should().Be("/*[local-name()='configuration']/*[local-name()='appSettings']/*[local-name()='add' and (@key = 'second_setting')]"); }
public void CreateSucceedsForNodeUpdateChangeWithAttributeUpdate() { ConfigurationCommandFactory .Create( Files.Load("update-node-change-with-attribute-update.config") .AsXPathNavigator() .SelectSingleNode("/configuration/system.net")) .Should().NotBeNull() .And.BeOfType <ElementUpdateCommand>() .Subject.AttributeSpecifications.Should() .ContainSingle(update => update.Name == "test" && update.Value == "true"); }
public static void SetCase(int caseIndex) { if (me == null) { me = FindObjectOfType <InvestigationManager>(); } me.currentCase = caseIndex; Files files = Files.Load(); files.openedCase = caseIndex; files.Save(); }
public void CreateSucceedsForNodeInsertionChange() { var elementInsertionDefinition = ConfigurationCommandFactory.Create( Files .Load("create-node-change.config") .AsXPathNavigator() .SelectSingleNode("/configuration/system.net")) .Should().NotBeNull() .And.BeOfType <ElementInsertionCommand>().Subject.ElementSpecification; elementInsertionDefinition.Name.Should().Be("system.net"); elementInsertionDefinition.NamespaceUri.Should().BeNullOrEmpty(); elementInsertionDefinition.Selector.Should().Be("*[local-name()='system.net']"); }
public void CreateSucceedsForNodeInsertionChangeWithDiscriminant() { var elementInsertionDefinition = ConfigurationCommandFactory .Create( Files.Load("create-node-change-with-discriminant.config") .AsXPathNavigator() .SelectSingleNode("/configuration/system.net/connectionManagement/add")) .Should().NotBeNull() .And.BeOfType <ElementInsertionCommand>().Subject .ElementSpecification; elementInsertionDefinition.Name.Should().Be("add"); elementInsertionDefinition.NamespaceUri.Should().BeNullOrEmpty(); elementInsertionDefinition.Selector.Should().Be("*[local-name()='add' and (@address = '*')]"); }
public Form1() { InitializeComponent(); Collections = Files.Load(); CurrentCollection = Collections.FirstOrDefault(); foreach (var collection in Collections) { cbxTheme.Items.Add(collection.Theme); } CorrectlyAnswered = 0; }
public async Task Run() { var config = Files.Load <Configuration>(Files.Paths.ConfigXml); if (config == null) { this.log.Print("No configuration loaded"); return; } await this.DownloadOrders(config); await this.DownloadBank(config); // send emails }
private IReadOnlyList <IFiles> GetIFilesCore(string directory) { Logger.Verbose("ManagerController:GetFilesCore Start"); var databases = new List <IFiles>(); var failedToLoadDatabases = new List <string>(); string[] supportedFileTypes = Enum.GetNames(typeof(BlogTypes)).ToArray(); foreach (string filename in Directory.GetFiles(directory, "*").Where( fileName => supportedFileTypes.Any(fileName.Contains) && fileName.Contains("_files"))) { //TODO: Refactor try { IFiles database = Files.Load(filename); if (_shellService.Settings.LoadAllDatabases) { databases.Add(database); } } catch (SerializationException ex) { failedToLoadDatabases.Add(ex.Data["Filename"].ToString()); } } if (failedToLoadDatabases.Any()) { IEnumerable <IBlog> blogs = _managerService.BlogFiles; IEnumerable <IBlog> failedToLoadBlogs = blogs.Where(blog => failedToLoadDatabases.Contains(blog.ChildId)).ToList(); string failedBlogNames = failedToLoadDatabases.Aggregate((a, b) => a + ", " + b); Logger.Verbose("ManagerController:GetIFilesCore: {0}", failedBlogNames); _shellService.ShowError(new SerializationException(), Resources.CouldNotLoadLibrary, failedBlogNames); foreach (IBlog failedToLoadBlog in failedToLoadBlogs) { _managerService.BlogFiles.Remove(failedToLoadBlog); } } Logger.Verbose("ManagerController.GetFilesCore End"); return(databases); }
public void Ask(ClueData clue) { CaseData openedCase = InvestigationManager.GetCase(); foreach (var testimony in data.testimonys) { if (testimony.clue == clue) { Files files = Files.Load(); bool added = files.GetCaseStatus().AddTestimony(openedCase.GetTestimonyFromData(testimony)); files.Save(); DialogUI.StartDialog(testimony.findingDialog, added, DialogType.TESTIMONY); return; } } DialogUI.StartDialog(data.genericNegativeAnswers[Random.Range(0, data.genericNegativeAnswers.Count)]); }
public void Ask(WitnessData witness) { CaseData openedCase = InvestigationManager.GetCase(); foreach (var rumor in data.rumors) { if (rumor.target == witness) { Files files = Files.Load(); bool added = files.GetCaseStatus().AddRumor(openedCase.GetRumorFromData(rumor)); files.Save(); DialogUI.StartDialog(rumor.findingDialog, added, DialogType.RUMOR); return; } } DialogUI.StartDialog(data.genericNegativeAnswers[Random.Range(0, data.genericNegativeAnswers.Count)]); }
private IFiles LoadFiles(IBlog blog) { if (settings.LoadAllDatabases) { var files = managerService.Databases.FirstOrDefault(file => file.Name.Equals(blog.Name) && file.BlogType.Equals(blog.OriginalBlogType)); if (files == null) { var s = string.Format("{0} ({1})", blog.Name, blog.BlogType); Logger.Error(Resources.CouldNotLoadLibrary, s); shellService.ShowError(new KeyNotFoundException(), Resources.CouldNotLoadLibrary, s); throw new KeyNotFoundException(s); } return(files); } return(Files.Load(blog.ChildId)); }
void OnEnable() { _files = new Files(); _views = new List<GOBResourceViewer>(); _files.Initialize(); // PAL to use using (PAL pal = Asset.New("RAMSHED.PAL", _files.Load("RAMSHED.PAL"), Asset.Type.PAL, null) as PAL) { BM.CreateArgs bmCreateArgs = new BM.CreateArgs(); bmCreateArgs.FilterMode = FilterMode.Point; bmCreateArgs.bMipmap = false; bmCreateArgs.AnisoLevel = 0; bmCreateArgs.Pal = pal; foreach (var gob in _files.GOBs) { foreach (var file in gob.Files) { switch (Asset.TypeForName(file.Name)) { case Asset.Type.BM: _views.Add(new GOBBMViewer(Asset.Load(file, bmCreateArgs) as BM)); break; case Asset.Type.FME: _views.Add(new GOBFMEViewer(Asset.Load(file, bmCreateArgs) as FME)); break; } } } } }