public void ItemsShouldBeRetrieved() { // Arrange var dictionary = new IdentifierDictionary<string>(); var items = new[] {"a", "b", "c"}; // Act foreach (var item in items) dictionary.GetId(item); // Assert CollectionAssert.AreEqual(items, dictionary.Items); }
public void ItemsShouldNotBeAssignedNewIdentifiersWhenCheckedAgain() { // Arrange var dictionary = new IdentifierDictionary<string>(); // Act for (var i = 0; i < 30; ++i) dictionary.GetId((i % 3).ToString()); // Assert Assert.That(dictionary.Count, Is.EqualTo(3)); Assert.That(dictionary.GetId("0"), Is.EqualTo(0)); Assert.That(dictionary.GetId("1"), Is.EqualTo(1)); Assert.That(dictionary.GetId("2"), Is.EqualTo(2)); }
public void ItemsShouldBeRetrieved() { // Arrange var dictionary = new IdentifierDictionary <string>(); var items = new[] { "a", "b", "c" }; // Act foreach (var item in items) { dictionary.GetId(item); } // Assert CollectionAssert.AreEqual(items, dictionary.Items); }
public void NewItemsShouldBeAssignedIdentifiersInSequentialOrder() { // Arrange var dictionary = new IdentifierDictionary<string>(); // Act var a = dictionary.GetId("a"); var b = dictionary.GetId("b"); var c = dictionary.GetId("c"); // Assert Assert.That(dictionary.Count, Is.EqualTo(3)); Assert.That(a, Is.EqualTo(0)); Assert.That(b, Is.EqualTo(1)); Assert.That(c, Is.EqualTo(2)); }
public void NewItemsShouldBeAssignedIdentifiersInSequentialOrder() { // Arrange var dictionary = new IdentifierDictionary <string>(); // Act var a = dictionary.GetId("a"); var b = dictionary.GetId("b"); var c = dictionary.GetId("c"); // Assert Assert.That(dictionary.Count, Is.EqualTo(3)); Assert.That(a, Is.EqualTo(0)); Assert.That(b, Is.EqualTo(1)); Assert.That(c, Is.EqualTo(2)); }
public void SameDictionariesShouldBeEqual() { // Arrange var d1 = new IdentifierDictionary <string>(); var d2 = new IdentifierDictionary <string>(); var items = new[] { "a", "b", "c", "d", "e" }; // Act foreach (var item in items) { d1.GetId(item); d2.GetId(item); } // Assert Assert.AreEqual(d1, d2); }
public void ItemsShouldNotBeAssignedNewIdentifiersWhenCheckedAgain() { // Arrange var dictionary = new IdentifierDictionary <string>(); // Act for (var i = 0; i < 30; ++i) { dictionary.GetId((i % 3).ToString()); } // Assert Assert.That(dictionary.Count, Is.EqualTo(3)); Assert.That(dictionary.GetId("0"), Is.EqualTo(0)); Assert.That(dictionary.GetId("1"), Is.EqualTo(1)); Assert.That(dictionary.GetId("2"), Is.EqualTo(2)); }
public void DictionariesWithSameElementsButDifferentOrderOfAdditionShouldNotBeEqual() { // Arrange var d1 = new IdentifierDictionary<string>(); var d2 = new IdentifierDictionary<string>(); var items1 = new[] { "a", "b", "c", "d", "e" }; var items2 = new[] { "a", "b", "d", "c", "e" }; // Act foreach (var item in items1) d1.GetId(item); foreach (var item in items2) d2.GetId(item); // Assert Assert.AreNotEqual(d1, d2); }
public void DictionariesWithSameElementsButDifferentOrderOfAdditionShouldNotBeEqual() { // Arrange var d1 = new IdentifierDictionary <string>(); var d2 = new IdentifierDictionary <string>(); var items1 = new[] { "a", "b", "c", "d", "e" }; var items2 = new[] { "a", "b", "d", "c", "e" }; // Act foreach (var item in items1) { d1.GetId(item); } foreach (var item in items2) { d2.GetId(item); } // Assert Assert.AreNotEqual(d1, d2); }
internal CldrTree() { this.Root = new CldrTreeNode(this, null); this.Values = new List<string>(); this.Locales = new IdentifierDictionary<CldrLocale>(); }
public StructureTable() { _table = new IdentifierDictionary<StructureType>(4, 16); }
public HeaderFileLoader(EmueraConsole main, IdentifierDictionary idDic, Process proc) { output = main; parentProcess = proc; this.idDic = idDic; }
public PropertyBag() { _table = new List <IProperty>(8); _properties = new IdentifierDictionary <IProperty>(4, 8); }
public void SameDictionariesShouldBeEqual() { // Arrange var d1 = new IdentifierDictionary<string>(); var d2 = new IdentifierDictionary<string>(); var items = new[] {"a", "b", "c", "d", "e"}; // Act foreach (var item in items) { d1.GetId(item); d2.GetId(item); } // Assert Assert.AreEqual(d1, d2); }
public CldrTreeBuilder() { this.values = new IdentifierDictionary<string>(); this.Tree = new CldrTree(); }
//テンプレートからEpubファイルを作成する public bool GenerateEpubDocument() { //ファイルの上書きを確認する var epubFileName = GetEpubFileName(); if (File.Exists(epubFileName)) { var overwrite = MessageBox.Show("ファイルを上書きしますか?", "Nov2Epub", MessageBoxButton.OKCancel); if (overwrite == MessageBoxResult.OK) { File.Delete(epubFileName); } else //上書きしないならそのまま終了 { return(false); } } //テンプレートファイルをテンポラリディレクトリにコピーする var templateDir = GetTemplateDirectory(); //テンプレートディレクトリ var tempDir = Path.GetTempPath(); //テンポラリディレクトリ var epubDirName = Path.Combine(tempDir, Path.GetFileNameWithoutExtension(Path.GetRandomFileName())); //ランダム CopyDirectory(templateDir, epubDirName); //コピーする //パッケージドキュメントを更新する var packFile = ContainerXML.GetPackageDocument(epubDirName); PackageDocument.WriteMetaData(packFile, metaData); //表紙ファイルを更新する var coverImageDst = Path.Combine(epubDirName, @"OEBPS\Images\Cover.JPG"); File.Copy(coverImageFileName, coverImageDst, true); //扉ページを更新する var titlePageDst = Path.Combine(epubDirName, @"OEBPS\Text\Title.xhtml"); InfoPage.UpdateTitlePage(titlePageDst, metaData); //テキストを更新する var textTemplateFile = Path.Combine(epubDirName, @"OEBPS\Text\Text.xhtml"); var headerAnchors = TextConverter.ConvertText(novelFileName, textTemplateFile, opt); //本文の縦書き/横書きをCSSに設定する var textCssTemplateFile = Path.Combine(epubDirName, @"OEBPS\Styles\Text.css"); TextStyleSheet.SetOrientationStyle(textCssTemplateFile, metaData.isVertical); //目次の縦書き/横書きをCSSに設定する var navCssTemplateFile = Path.Combine(epubDirName, @"OEBPS\Styles\Nav.css"); TextStyleSheet.SetOrientationStyle(navCssTemplateFile, metaData.isVertical); //ナビゲーションドキュメントを作成する var navFileName = Path.Combine(epubDirName, @"OEBPS\Text\nav.xhtml"); NavigationDocument.WriteNavigationDocument(navFileName, headerAnchors); //奥付ページを更新する var ColophonPage = Path.Combine(epubDirName, @"OEBPS\Text\Colophon.xhtml"); InfoPage.UpdateTitlePage(ColophonPage, metaData); //不要ファイルを削除する var thumbsFile = Path.Combine(epubDirName, @"OEBPS\Images\Thumbs.db"); if (File.Exists(thumbsFile) == true) { File.Delete(thumbsFile); } //EPubファイルを作成する Archiver.ArchiveEpubWithPostProcess(epubDirName, epubFileName); //テンポラリディレクトリを削除する Directory.Delete(epubDirName, true); //Identifierを更新する IdentifierDictionary.SaveIdentifierDictionary(); return(true); }
public PropertyBag(Context context) { _context = context; _table = new List <Property>(8); _properties = new IdentifierDictionary <Property>(4, 8); }
public StructureTable() { _table = new IdentifierDictionary <StructureType>(4, 16); }
public ArchitectureTable() { _table = new IdentifierDictionary<List<IArchitectureFactory>>(4, 16); }
public static LogicalLine ParseLabelLine(StringStream stream, ScriptPosition position, EmueraConsole console) { var isFunction = stream.Current == '@'; var lineNo = position.LineNo; var labelName = ""; var errMes = ""; try { var warnLevel = -1; stream.ShiftNext(); //@か$を除去 var wc = LexicalAnalyzer.Analyse(stream, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment); if (wc.EOL || !(wc.Current is IdentifierWord)) { errMes = "関数名が不正であるか存在しません"; goto err; } labelName = ((IdentifierWord)wc.Current).Code; wc.ShiftNext(); if (Config.ICVariable) { labelName = labelName.ToUpper(); } GlobalStatic.IdentifierDictionary.CheckUserLabelName(ref errMes, ref warnLevel, isFunction, labelName); if (warnLevel >= 0) { if (warnLevel >= 2) { goto err; } ParserMediator.Warn(errMes, position, warnLevel); } if (!isFunction) //$ならこの時点で終了 { if (!wc.EOL) { ParserMediator.Warn("$で始まるラベルに引数が設定されています", position, 1); } return(new GotoLabelLine(position, labelName)); } //labelName = LexicalAnalyzer.ReadString(stream, StrEndWith.LeftParenthesis_Bracket_Comma_Semicolon); //labelName = labelName.Trim(); //if (Config.ICVariable) // labelName = labelName.ToUpper(); //GlobalStatic.IdentifierDictionary.CheckUserLabelName(ref errMes, ref warnLevel, isFunction, labelName); //if(warnLevel >= 0) //{ // if (warnLevel >= 2) // goto err; // ParserMediator.Warn(errMes, position, warnLevel); //} //if (!isFunction)//$ならこの時点で終了 //{ // LexicalAnalyzer.SkipWhiteSpace(stream); // if (!stream.EOS) // ParserMediator.Warn("$で始まるラベルに引数が設定されています", position, 1); // return new GotoLabelLine(position, labelName); //} ////関数名部分に_renameを使えないように変更 //if (ParserMediator.RenameDic != null && ((stream.ToString().IndexOf("[[") >= 0) && (stream.ToString().IndexOf("]]") >= 0))) //{ // string line = stream.ToString(); // foreach (KeyValuePair<string, string> pair in ParserMediator.RenameDic) // line = line.Replace(pair.Key, pair.Value); // stream = new StringStream(line); //} //WordCollection wc = null; //wc = LexicalAnalyzer.Analyse(stream, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment); if (Program.AnalysisMode) { console.PrintC("@" + labelName, false); } var funclabelLine = new FunctionLabelLine(position, labelName, wc); if (IdentifierDictionary.IsEventLabelName(labelName)) { funclabelLine.IsEvent = true; funclabelLine.IsSystem = true; funclabelLine.Depth = 0; } else if (IdentifierDictionary.IsSystemLabelName(labelName)) { funclabelLine.IsSystem = true; funclabelLine.Depth = 0; } return(funclabelLine); } catch (CodeEE e) { errMes = e.Message; } err: SystemSounds.Hand.Play(); if (isFunction) { if (labelName.Length == 0) { labelName = "<Error>"; } return(new InvalidLabelLine(position, labelName, errMes)); } return(new InvalidLine(position, errMes)); }
public bool Initialize() { LexicalAnalyzer.UseMacro = false; state = new ProcessState(console); originalState = state; initialiing = true; try { ParserMediator.Initialize(console); if (ParserMediator.HasWarning) { ParserMediator.FlushWarningList(); if (MessageBox.Show("コンフィグファイルに異常があります\nEmueraを終了しますか", "コンフィグエラー", MessageBoxButtons.YesNo) == DialogResult.Yes) { console.PrintLine("コンフィグファイルに異常があり、終了が選択されたため処理を終了しました"); return false; } } if (Config.UseKeyMacro && !Program.AnalysisMode) { if (File.Exists(Program.ExeDir + "macro.txt")) { if (Config.DisplayReport) console.PrintLine("macro.txt読み込み中・・・"); KeyMacro.LoadMacroFile(Program.ExeDir + "macro.txt"); } } if (Config.UseReplaceFile && !Program.AnalysisMode) { if (File.Exists(Program.CsvDir + "_Replace.csv")) { if (Config.DisplayReport) console.PrintLine("_Replace.csv読み込み中・・・"); ConfigData.Instance.LoadReplaceFile(Program.CsvDir + "_Replace.csv"); if (ParserMediator.HasWarning) { ParserMediator.FlushWarningList(); if (MessageBox.Show("_Replace.csvに異常があります\nEmueraを終了しますか", "_Replace.csvエラー", MessageBoxButtons.YesNo) == DialogResult.Yes) { console.PrintLine("_Replace.csvに異常があり、終了が選択されたため処理を終了しました"); return false; } } } } Config.SetReplace(ConfigData.Instance); //ここでBARを設定すれば、いいことに気づいた予感 console.setStBar(Config.DrawLineString); if (Config.UseRenameFile) { if (File.Exists(Program.CsvDir + "_Rename.csv")) { if (Config.DisplayReport || Program.AnalysisMode) console.PrintLine("_Rename.csv読み込み中・・・"); ParserMediator.LoadEraExRenameFile(Program.CsvDir + "_Rename.csv"); } else console.PrintError("csv\\_Rename.csvが見つかりません"); } if (!Config.DisplayReport) { console.PrintLine(Config.LoadLabel); console.RefreshStrings(true); } gamebase = new GameBase(); gamebase.LoadGameBaseCsv(Program.CsvDir + "GAMEBASE.CSV"); console.SetWindowTitle(gamebase.ScriptWindowTitle); GlobalStatic.GameBaseData = gamebase; ConstantData constant = new ConstantData(gamebase); constant.LoadData(Program.CsvDir, console, Config.DisplayReport); GlobalStatic.ConstantData = constant; TrainName = constant.GetCsvNameList(VariableCode.TRAINNAME); vEvaluator = new VariableEvaluator(gamebase, constant); GlobalStatic.VEvaluator = vEvaluator; idDic = new IdentifierDictionary(vEvaluator.VariableData); GlobalStatic.IdentifierDictionary = idDic; StrForm.Initialize(); VariableParser.Initialize(); exm = new ExpressionMediator(this, vEvaluator, console); GlobalStatic.EMediator = exm; labelDic = new LabelDictionary(); GlobalStatic.LabelDictionary = labelDic; HeaderFileLoader hLoader = new HeaderFileLoader(console, idDic, this); LexicalAnalyzer.UseMacro = false; if (!hLoader.LoadHeaderFiles(Program.ErbDir, Config.DisplayReport)) { console.PrintLine("ERHの読み込み中にエラーが発生したため処理を終了しました"); return false; } LexicalAnalyzer.UseMacro = idDic.UseMacro(); ErbLoader loader = new ErbLoader(console, exm, this); if (Program.AnalysisMode) noError = loader.loadErbs(Program.AnalysisFiles, labelDic); else noError = loader.LoadErbFiles(Program.ErbDir, Config.DisplayReport, labelDic); initSystemProcess(); initialiing = false; } catch (Exception e) { handleException(e, null, true); console.PrintLine("初期化中に致命的なエラーが発生したため処理を終了しました"); return false; } if (labelDic == null) { return false; } state.Begin(BeginType.TITLE); GC.Collect(); return true; }
public bool Initialize() { LexicalAnalyzer.UseMacro = false; state = new ProcessState(console); originalState = state; initialiing = true; try { ParserMediator.Initialize(console); if (ParserMediator.HasWarning) { ParserMediator.FlushWarningList(); if (MessageBox.Show("コンフィグファイルに異常があります\nEmueraを終了しますか", "コンフィグエラー", MessageBoxButtons.YesNo) == DialogResult.Yes) { console.PrintSystemLine("コンフィグファイルに異常があり、終了が選択されたため処理を終了しました"); return(false); } } Content.AppContents.LoadContents(); if (Config.UseKeyMacro && !Program.AnalysisMode) { if (File.Exists(Program.ExeDir + "macro.txt")) { if (Config.DisplayReport) { console.PrintSystemLine("macro.txt読み込み中・・・"); } KeyMacro.LoadMacroFile(Program.ExeDir + "macro.txt"); } } if (Config.UseReplaceFile && !Program.AnalysisMode) { if (File.Exists(Program.CsvDir + "_Replace.csv")) { if (Config.DisplayReport) { console.PrintSystemLine("_Replace.csv読み込み中・・・"); } ConfigData.Instance.LoadReplaceFile(Program.CsvDir + "_Replace.csv"); if (ParserMediator.HasWarning) { ParserMediator.FlushWarningList(); if (MessageBox.Show("_Replace.csvに異常があります\nEmueraを終了しますか", "_Replace.csvエラー", MessageBoxButtons.YesNo) == DialogResult.Yes) { console.PrintSystemLine("_Replace.csvに異常があり、終了が選択されたため処理を終了しました"); return(false); } } } } Config.SetReplace(ConfigData.Instance); //ここでBARを設定すれば、いいことに気づいた予感 console.setStBar(Config.DrawLineString); if (Config.UseRenameFile) { if (File.Exists(Program.CsvDir + "_Rename.csv")) { if (Config.DisplayReport || Program.AnalysisMode) { console.PrintSystemLine("_Rename.csv読み込み中・・・"); } ParserMediator.LoadEraExRenameFile(Program.CsvDir + "_Rename.csv"); } else { console.PrintError("csv\\_Rename.csvが見つかりません"); } } if (!Config.DisplayReport) { console.PrintSingleLine(Config.LoadLabel); console.RefreshStrings(true); } gamebase = new GameBase(); if (!gamebase.LoadGameBaseCsv(Program.CsvDir + "GAMEBASE.CSV")) { console.PrintSystemLine("GAMEBASE.CSVの読み込み中に問題が発生したため処理を終了しました"); return(false); } console.SetWindowTitle(gamebase.ScriptWindowTitle); GlobalStatic.GameBaseData = gamebase; ConstantData constant = new ConstantData(gamebase); constant.LoadData(Program.CsvDir, console, Config.DisplayReport); GlobalStatic.ConstantData = constant; TrainName = constant.GetCsvNameList(VariableCode.TRAINNAME); vEvaluator = new VariableEvaluator(gamebase, constant); GlobalStatic.VEvaluator = vEvaluator; idDic = new IdentifierDictionary(vEvaluator.VariableData); GlobalStatic.IdentifierDictionary = idDic; StrForm.Initialize(); VariableParser.Initialize(); exm = new ExpressionMediator(this, vEvaluator, console); GlobalStatic.EMediator = exm; labelDic = new LabelDictionary(); GlobalStatic.LabelDictionary = labelDic; HeaderFileLoader hLoader = new HeaderFileLoader(console, idDic, this); LexicalAnalyzer.UseMacro = false; if (!hLoader.LoadHeaderFiles(Program.ErbDir, Config.DisplayReport)) { console.PrintSystemLine("ERHの読み込み中にエラーが発生したため処理を終了しました"); return(false); } LexicalAnalyzer.UseMacro = idDic.UseMacro(); ErbLoader loader = new ErbLoader(console, exm, this); if (Program.AnalysisMode) { noError = loader.loadErbs(Program.AnalysisFiles, labelDic); } else { noError = loader.LoadErbFiles(Program.ErbDir, Config.DisplayReport, labelDic); } initSystemProcess(); initialiing = false; } catch (Exception e) { handleException(e, null, true); console.PrintSystemLine("初期化中に致命的なエラーが発生したため処理を終了しました"); return(false); } if (labelDic == null) { return(false); } state.Begin(BeginType.TITLE); GC.Collect(); return(true); }
public CldrTreeBuilder() { this.values = new IdentifierDictionary <string>(); this.Tree = new CldrTree(); }