/// <summary> /// Replaces the string aliases. /// In some cases an action string in configuration file has to be specified by an alias. /// </summary> private void ReplaceStringAliases() { var resources = new ResXResourceSet(ConfigurationManager.AppSettings["KeyAliasesResxFileName"]); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("backslash", "\\")).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("lclick", resources.GetString("leftMouseClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("ldclick", resources.GetString("leftMouseDoubleClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("lhclick", resources.GetString("leftMouseHoldClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("rclick", resources.GetString("rightMouseClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("rdclick", resources.GetString("rightMouseDoubleClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace("rhclick", resources.GetString("rightMouseHoldClick"))).ToList(); ActionStringKeys = ActionStringKeys.Select(x => Regex.Replace(x, "^ $", resources.GetString("spacebar") ?? "spacebar")).ToList(); ActionStringKeys = ActionStringKeys.Select(x => x.Replace(@"/'/'", @"""""")).ToList(); }
public void CloneValuesTest() { string key = "TestBinFile"; var path = Combine(Files.GetExecutingPath(), "Resources", "TestResourceResX.resx"); var rs = new ResXResourceSet(path); Assert.IsFalse(rs.CloneValues); Assert.IsTrue(rs.AutoFreeXmlData); // if not cloning values, references are the same for subsequent calls Assert.AreSame(rs.GetObject(key), rs.GetObject(key)); // if cloning values, references are different rs.CloneValues = true; Assert.AreNotSame(rs.GetObject(key), rs.GetObject(key)); // but strings are always the same reference key = "TestString"; Assert.AreSame(rs.GetObject(key), rs.GetObject(key)); Assert.AreSame(rs.GetString(key), rs.GetString(key)); }
// -------------------------------------------------------------------------------------------------------------------------------- public override void SetTextToActiveLanguage() { if ((_shownLanguage == PAPIApplication.GetLanguage() && PAPIApplication._runningGame != null && shownGenre == PAPIApplication._runningGame._genre)) { return; } using (ResXResourceSet resSet = new ResXResourceSet(GetTranslationFile())) { Translate(resSet, genreLabel); if (PAPIApplication._runningGame != null) { genreLabel.Text += ": " + TranslatedString(resSet, EnumConverter.Convert(PAPIApplication._runningGame._genre)); Translate(resSet, creationDateLabel); creationDateLabel.Text += ": " + PAPIApplication._runningGame._dateOfCreation.ToString(); Translate(resSet, lastSaveLabel); lastSaveLabel.Text += ": " + PAPIApplication._runningGame._dateOfLastSession.ToString(); } } }
public static void Main() { CreateResXFile(); ResXResourceSet resSet = new ResXResourceSet(@".\StoreResources.resx"); IDictionaryEnumerator dict = resSet.GetEnumerator(); while (dict.MoveNext()) { string key = (string)dict.Key; // Retrieve resource by name. if (dict.Value is string) { Console.WriteLine("{0}: {1}", key, resSet.GetString(key)); } else { Console.WriteLine("{0}: {1}", key, resSet.GetObject(key)); } } }
private void InitializeStickers() { canvasImage.AllowDrop = true; //TODO Change this to avoid hardcore programming string resXfile = @".\Resources.resx"; string path; using (ResXResourceSet resultSet = new ResXResourceSet(resXfile)) { path = resultSet.GetString("stickers"); } dc = new DrawingCanvas(canvasImage); string[] dirs = Directory.GetDirectories(path); foreach (string dir in dirs) { InitializeStickerPack(dir); } }
public ResourceManager(string ResxFile) : this() { System.IO.FileInfo f = new System.IO.FileInfo(ResxFile); if (f.Exists) { var st = new ResXResourceSet(ResxFile); foreach (DictionaryEntry e in st) { IResourceHolder hld = loader.CreateHolderInstance(e.Key.ToString(), e.Value); if (hld != null) { List.Add(hld); } else { incomplete = true; } } st.Close(); } fileName = ResxFile; }
public Image GetImage() { try { using (ResXResourceSet resxLoad = new ResXResourceSet(@".\Logo.resx")) { img = (Image)resxLoad.GetObject("LogoPicture", true); if (img == null) { img = (Image)rm.GetObject("DefaultLogoPOT"); } } } catch (Exception e1) { new LogWriter(e1); img = (Image)rm.GetObject("DefaultLogoPOT"); } return(img); }
private async void button10_Click(object sender, EventArgs e) { try { ResXResourceSet resX = new ResXResourceSet(Resources.ResourceManager.BaseName); byte[] _byteArr = (byte[])resX.GetObject("resource1"); if (!(_byteArr.Equals(null))) { Bitmap bitmap = await ByteToImageAsync(_byteArr); pictureBox1.Image = bitmap; textBox1.AppendText($"res added to picBox{Environment.NewLine}"); } resX.Close(); resX.Dispose(); resX = null; } catch (Exception exc) { textBox1.AppendText($"res not added to pic => {exc.ToString()}{Environment.NewLine}"); } }
public void NonSerializableObject() { var rs = new ResXResourceSet(); rs.SetObject("x", new NonSerializableClass { Prop = 1 }); var sb = new StringBuilder(); rs.Save(new StringWriter(sb), true); var rsCheck = new ResXResourceSet(new StringReader(sb.ToString())); Assert.AreEqual(rs.GetObject("x"), rsCheck.GetObject("x")); sb = new StringBuilder(); rs.Save(new StringWriter(sb), false); rsCheck = new ResXResourceSet(new StringReader(sb.ToString())); Assert.AreEqual(rs.GetObject("x"), rsCheck.GetObject("x")); }
private void LessonForm_Load(object sender, EventArgs e) { using (ResXResourceSet resxSet = new ResXResourceSet(resxFile)) { acess_token = resxSet.GetString("acess_token"); string id_discipline = resxSet.GetString("id_discipline"); var id_exercize = resxSet.GetString("id_exercize"); Console.WriteLine(acess_token + "taken"); //добавить функцию var response_content = File.GetContentInfo(acess_token, id_discipline, id_exercize); Root <Data> exercize = JsonConvert.DeserializeObject <Root <Data> >(response_content); string url = exercize.data.content.file.url; Console.WriteLine(APP_PATH + url); WebClient webClient = new WebClient(); var response_file = File.GetFileInfo(acess_token, id_discipline, id_exercize); Root <List <Content> > code = JsonConvert.DeserializeObject <Root <List <Content> > >(response_file); Console.WriteLine(code); if (code.data.Count == 0) { Console.WriteLine(code.data); richTextBox1.Text = "В данном уроке отсутствует код для компиляции"; } else { string url_code = code.data[0].file.url; Console.WriteLine(APP_PATH + url_code); richTextBox1.Text = webClient.DownloadString(APP_PATH + url_code); } byte[] bytes = Encoding.Default.GetBytes(webClient.DownloadString(APP_PATH + url)); string myString = Encoding.UTF8.GetString(bytes); var html = Markdig.Markdown.ToHtml(myString); webBrowser1.DocumentText = html; } }
private void OpenResXFile(string fileName) { FileStream file; try { xmlDocument = new XmlDataDocument(); xmlDocument.DataSet.ReadXmlSchema(fileName); file = new FileStream(fileName, FileMode.Open, FileAccess.Read); xmlDocument.Load(file); file.Close(); xmlGridView.DataSource = xmlDocument.DataSet; xmlGridView.DataMember = "data"; //we need this to exclude non-text fields file = new FileStream(fileName, FileMode.Open, FileAccess.Read); resourceSet = new ResXResourceSet(file); OnResXFileOpened(); } catch (Exception ex) { isDocumentOpen = false; Program.ShowException(ex, "Open ResX File Error!"); return; } resxFileName = fileName; InitGrid(); UpdateGridViewFilter(); file.Close(); isDataModified = false; isDocumentOpen = true; UpdateForm(); }
private void ShowWorldMap(Dictionary <KeyValuePair <int, int>, Terrain> terrainDictionary) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); worldMap = new WorldMap(128, 10, 10, terrainDictionary); int maxindex = size - 1; string resxFile = "Resources.resx"; using (ResXResourceSet resxSet = new ResXResourceSet(resxFile)) { for (int i = 0; i < maxindex; i++) { for (int j = 0; j < maxindex; j++) { KeyValuePair <int, int> keyValuePair = new KeyValuePair <int, int>(i, j); Terrain terrain = terrainDictionary[keyValuePair]; Image image = (Image)resxSet.GetObject(terrain.Picture, true); if (image != null) { terrain.Image = image; } worldMap.FillCell(i, j, terrain); } } } Application.Run(worldMap); } catch (Exception e) { throw e; } }
private static string ProcessMessage(string messageNumber) { try { var path = ObtenerPath(); using (ResXResourceSet resxSet = new ResXResourceSet(path)) { foreach (DictionaryEntry item in resxSet) { if (item.Key != null && (string)item.Key == messageNumber) { return(item.Value.ToString()); } } } } catch (Exception ex) { Log.ErrorFormat("Ocurrio un error al leer el idioma del archivo de recursos. Error: {0}", ex.Message); } return(null); }
//激活更新 private void Form1_Activated(object sender, EventArgs e) { string respath = @".\Resource1.resx"; //读取资源文件的值 using (ResXResourceSet rest = new ResXResourceSet(respath)) { codestart = Convert.ToInt32(rest.GetString("Ocr_start_text")); cX = Convert.ToInt32(rest.GetString("x")); cY = Convert.ToInt32(rest.GetString("y")); cH = Convert.ToInt32(rest.GetString("h")); cW = Convert.ToInt32(rest.GetString("w")); this.label7.Text = "(" + codestart.ToString() + "," + cX.ToString() + "," + cY.ToString() + "," + cH.ToString() + "," + cW.ToString() + ")"; } /* * cX = Convert.ToInt32(this.textX.Text); * cY = Convert.ToInt32(this.textY.Text); * cW = Convert.ToInt32(this.textW.Text); * cH = Convert.ToInt32(this.textH.Text); * codestart = Convert.ToInt32(this.textCodeStart.Text); */ }
private void RemoveUnsupportedItems(ResXResourceSet rs) { string[] unsupported = #if NETCOREAPP2_0 // .NET Core 2.0 Drawing and WinForms types are not supported { "System.Drawing", "System.Windows.Forms" }; #else // .NET Core 3.0 and above: Drawing and WinForms types are supported, only binary serialized types are removed new string[0]; #endif bool origMode = rs.SafeMode; rs.SafeMode = true; foreach (var item in rs.GetEnumerator().ToEnumerable <string, ResXDataNode>().ToList()) { if (item.Value.AssemblyQualifiedName?.ContainsAny(unsupported) == true || item.Value.FileRef?.TypeName.ContainsAny(unsupported) == true || item.Value.MimeType == ResXCommon.BinSerializedObjectMimeType) { rs.RemoveObject(item.Key); } } rs.SafeMode = origMode; }
public void GetStringSafe() { var path = Path.Combine(Files.GetExecutingPath(), "Resources\\TestResourceResX.resx"); var rs = new ResXResourceSet(path, null) { SafeMode = true }; object o; // when getting an object, result is always a ResXDataNode regardless of the object is a string Assert.IsInstanceOf <ResXDataNode>(o = rs.GetObject("TestString")); Assert.IsInstanceOf <ResXDataNode>(o = rs.GetObject("TestBytes")); // for a string, the string value is returned Assert.AreEqual("String invariant ResX", rs.GetString("TestString")); // for a non-string, the non-deserialized raw string value is returned Assert.AreEqual("576, 17", rs.GetString("TestPoint")); // for a file reference, the reference value is returned... Assert.IsTrue(rs.GetString("TestBinFile").StartsWith("TestBinFile.bin;System.Byte[], mscorlib", StringComparison.Ordinal)); // ...even if it refers to a string... Assert.IsTrue(rs.GetString("TestTextFile").StartsWith("TestTextFile.txt;System.String, mscorlib", StringComparison.Ordinal)); rs.SafeMode = false; o = rs.GetString("TestTextFile"); o = rs.GetObject("TestBinFile"); rs.SafeMode = true; // ...unless the string value is already obtained and cached Assert.IsFalse(rs.GetString("TestTextFile").StartsWith("TestTextFile.txt;System.String, mscorlib", StringComparison.Ordinal)); // but a non-string file reference will still return the file reference even if the result is cached (with AutoCleanup, this time with full path) Assert.IsTrue(rs.GetString("TestBinFile").Contains("TestBinFile.bin;System.Byte[], mscorlib")); }
private void ListLessonsForm_Load(object sender, EventArgs e) { using (ResXResourceSet resxSet = new ResXResourceSet(resxFile)) { acess_token = resxSet.GetString("acess_token"); id_discipline = resxSet.GetString("id_discipline"); Console.WriteLine(acess_token + "taken"); //MessageBox.Show(s, b); var response = Discipline.GetDisciplineInfo(acess_token, id_discipline); Root <List <Discipline> > discipline = JsonConvert.DeserializeObject <Root <List <Discipline> > > (response); //bindingSource1.DataSource = discipline.data; //ListViewItem item = null; //item = new ListViewItem(new string[] {Convert.ToString() }) //List<MainClass.ListDiscipline>.Enumerator; listBoxLesson.DataSource = discipline.data; listBoxLesson.DisplayMember = "name"; listBoxLesson.ValueMember = "id"; //listBoxCategory.DataBindings.Add("Text", bindingSource1, "name"); //richTextBox1.DataBindings.Add("Text", bindingSource1, "description"); //foreach (var x in discipline.data) //{ // listBoxCategory.Items.Add(x.name); // var name = x.name; // Console.WriteLine(name); //} //var response = MainClass.Person.GetUserInfo(); //Console.WriteLine("Статус запроса: {0}", response.StatusCode.ToString()); //Console.WriteLine("Ответ: {0}", response.Content.ReadAsStringAsync().Result); //richTextBox1.Text = response.Headers.ToString(); ////return response.StatusCode.ToString(); } }
// #region methods //Draws the array of pictureboxes in the desired place private void CreateTileBox(PictureBox[,] pb) { ResXResourceSet resSet = new ResXResourceSet(resX); for (int row = 0; row < SaveBox.GetLength(0); row++) { for (int col = 0; col < SaveBox.GetLength(1); col++) { SaveBox[row, col].Size = new Size(TILE_SIZE / (SaveBox.GetLength(1) / 2), TILE_SIZE / (SaveBox.GetLength(1) / 2)); if (SaveBox[row, col].Size.Width > 80) { SaveBox[row, col].Size = new Size(50, 50); } SaveBox[row, col].Location = new Point(279 + (SaveBox[row, col].Size.Width * col), 9 + (SaveBox[row, col].Size.Height * row)); SaveBox[row, col].Image = (System.Drawing.Image)resSet.GetObject("blackpaint");//makes the beginning canvas black SaveBox[row, col].Tag = "blackpaint"; SaveBox[row, col].SizeMode = PictureBoxSizeMode.StretchImage; Controls.Add(SaveBox[row, col]); SaveBox[row, col].MouseDown += delegate(object sender, MouseEventArgs e){ MapEdit_MouseClick(sender, e); }; SaveBox[row, col].MouseEnter += delegate(object sender, EventArgs e) { MapEdit_MouseDrag(sender, e); }; } } }
private static Dictionary <string, string> GetResourceKeyValueList(string resourceFilePath) { Dictionary <string, string> resourceKeyValues = new Dictionary <string, string>(); ResXResourceSet resSet = new ResXResourceSet(resourceFilePath); IDictionaryEnumerator dict = resSet.GetEnumerator(); while (dict.MoveNext()) { string key = (string)dict.Key; if (dict.Value is string) { resourceKeyValues.Add(key, resSet.GetString(key)); } else { resourceKeyValues.Add(key, resSet.GetObject(key).ToString()); } } return(resourceKeyValues); }
/// <summary> /// Inserts a topic into the database /// </summary> public void cmdAddTopic_Click(object sender, EventArgs e) { // If the app native language is set on French if (mainForm.dbConn.ReadSetting(1) == 2) { // Use French resxFile resxFile = @".\\stringsFR.resx"; } else { // By default use English resxFile resxFile = @".\\stringsEN.resx"; } using (ResXResourceSet resourceManager = new ResXResourceSet(resxFile)) { if (txtTopic.Text == "") { MessageBox.Show(resourceManager.GetString("youMustFillInANameForYourNewTopic"), resourceManager.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // Inserts the topic into the database mainForm.dbConn.InsertTopic(txtTopic.Text); // Reloads the topics list in the main form mainForm.LoadTopics(); // Selects the created topic in the combobox mainForm.cboTopics.SelectedIndex = mainForm.cboTopics.Items.Count - 1; // Closes the window this.Close(); } } }
public searchDialog() { InitializeComponent(); SearchDialogVisible.IsThisVisible = true; string Language = string.Empty; try { Language = string.Format(@".\Resources\Languages\{0}.resx", ConfigurationManager.AppSettings[WhatLanguageIsActivate.ThisLanguage].ToString()); } catch { } try { if (!string.IsNullOrWhiteSpace(Language)) { using (ResXResourceSet x = new ResXResourceSet(Language)) { this.Text = x.GetString("Search"); } } } catch { } }
public void SetRemoveObject() { var path = Combine(Files.GetExecutingPath(), "Resources", "TestResourceResX.resx"); var rs = new ResXResourceSet(path, null); // replace Assert.IsTrue(rs.GetObject("TestString") is string); rs.SetObject("TestString", 1); Assert.AreEqual(1, rs.GetObject("TestString")); // add new Assert.IsNull(rs.GetObject("NotExist")); rs.SetObject("NotExist", 2); Assert.IsNotNull(rs.GetObject("NotExist")); // delete rs.RemoveObject("TestString"); Assert.IsNull(rs.GetObject("TestString")); Assert.IsFalse(rs.GetEnumerator().GetKeysEnumerator().Any(e => e == "TestString")); // nullifying rs.SetObject("NotExist", null); Assert.IsNull(rs.GetObject("TestString")); Assert.IsTrue(rs.GetEnumerator().GetKeysEnumerator().Any(e => e == "NotExist")); // save and reload StringBuilder sb = new StringBuilder(); #if NETCOREAPP2_0 || NETCOREAPP3_0 RemoveUnsupportedItems(rs); #endif rs.Save(new StringWriter(sb)); var rsReloaded = new ResXResourceSet(new StringReader(sb.ToString()), Path.GetDirectoryName(path)); AssertItemsEqual(rs, rsReloaded); }
static void Main(string[] args) { string resxSourceFileEng = @"{to appp}\App_GlobalResources\LocalizedText.resx"; string resxSourceFileGerm = @"{to appp}\App_GlobalResources\LocalizedText.de-DE.resx"; string resxDestFileEng = @"{to appp}\App_GlobalResources\LocalizedText.resx"; string resxDestFileGerm = @"{to appp}\App_GlobalResources\LocalizedText.de-DE.resx"; List <ResXDataNode> existing = new List <ResXDataNode>(); List <DictionaryEntry> sourceRESXEng = new List <DictionaryEntry>(); List <DictionaryEntry> sourceRESXGerm = new List <DictionaryEntry>(); List <DictionaryEntry> destRESXEng = new List <DictionaryEntry>(); List <DictionaryEntry> destRESXGerm = new List <DictionaryEntry>(); ResXResourceReader sourceReaderEng = new ResXResourceReader(resxSourceFileEng); ResXResourceReader sourceReaderGerm = new ResXResourceReader(resxSourceFileGerm); ResXResourceReader destReaderEng = new ResXResourceReader(resxDestFileEng); ResXResourceReader destReaderGerm = new ResXResourceReader(resxDestFileGerm); ResXResourceWriter destWriterEng = new ResXResourceWriter(resxDestFileEng); ResXResourceWriter destWriterGerm = new ResXResourceWriter(resxDestFileGerm); foreach (DictionaryEntry entry in sourceReaderEng) { sourceRESXEng.Add(entry); } foreach (DictionaryEntry entry in sourceReaderGerm) { sourceRESXGerm.Add(entry); } foreach (DictionaryEntry entry in destReaderEng) { destRESXEng.Add(entry); } foreach (DictionaryEntry entry in destReaderGerm) { destRESXGerm.Add(entry); } ResXResourceSet resSetDestEng = new ResXResourceSet(resxDestFileEng); List <DictionaryEntry> engDiff = new List <DictionaryEntry>(); foreach (DictionaryEntry data in sourceRESXEng) { var dataExists = resSetDestEng.GetString(data.Key.ToString()); if (String.IsNullOrEmpty(dataExists)) { engDiff.Add(data); } } List <string> sameEngKeys = new List <string>(); foreach (var dat in engDiff) { var datKey = dat.Key.ToString(); var found = false; foreach (var des in destRESXEng) { var desKey = des.Key.ToString(); if (datKey.ToLower().ToString() == desKey.ToLower().ToString()) { found = true; sameEngKeys.Add(datKey); Console.WriteLine(datKey + " :: " + desKey); break; } } if (found == false) { destRESXEng.Add(dat); } } ResXResourceSet resSetDestGerm = new ResXResourceSet(resxDestFileEng); List <DictionaryEntry> germDiff = new List <DictionaryEntry>(); foreach (DictionaryEntry data in sourceRESXGerm) { var dataExists = resSetDestGerm.GetString(data.Key.ToString()); if (String.IsNullOrEmpty(dataExists)) { germDiff.Add(data); } } List <string> sameGermKeys = new List <string>(); foreach (var dat in germDiff) { var datKey = dat.Key.ToString(); var found = false; foreach (var des in destRESXGerm) { var desKey = des.Key.ToString(); if (datKey.ToLower().ToString() == desKey.ToLower().ToString()) { found = true; sameGermKeys.Add(datKey); //Console.WriteLine(datKey+" :: "+ desKey); break; } } if (found == false) { destRESXGerm.Add(dat); } } Console.WriteLine(sameGermKeys); Console.WriteLine("========================Eng file==========================="); foreach (var df in destRESXEng) { Console.WriteLine(df.Key.ToString() + ":\t \t \t" + df.Value.ToString()); ResXDataNode node = new ResXDataNode(df.Key.ToString(), df.Value.ToString()); destWriterEng.AddResource(node); } destWriterEng.Generate(); destWriterEng.Close(); Console.WriteLine("========================German file==========================="); foreach (var df in destRESXGerm) { Console.WriteLine(df.Key.ToString() + ":\t \t \t" + df.Value.ToString()); ResXDataNode node = new ResXDataNode(df.Key.ToString(), df.Value.ToString()); destWriterGerm.AddResource(node); } destWriterGerm.Generate(); destWriterGerm.Close(); Console.WriteLine("========================Done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!==========================="); Console.ReadKey(); }
protected void Edit() { if (Request.QueryString["key"] != null && Request.QueryString["file"] != null) { panelUpdate.Visible = true; filename = Request.QueryString["file"]; filename = Request.PhysicalApplicationPath + "App_GlobalResources\\" + filename; string key = Request.QueryString["key"]; lblKey.Text = key; ResXResourceSet rset = new ResXResourceSet(filename); txtResourceValue.Text = rset.GetString(key); } }
public static void Main(string[] args) { try { string lang = "cs-CZ"; // determine language localization //get access to CLR resource file var resPath = "Resource." + lang + ".resx"; // path to resource if buildинг from command prompt if (!System.IO.File.Exists(resPath)) Environment.CurrentDirectory = @"..\..\"; // path to resource if buildинг from Visual Studio var rs = new ResXResourceSet(resPath); //Prepare features // binaries Feature binaries = new Feature { Name = rs.GetString("FeatAppName"), ConfigurableDir = "APPLICATIONROOTDIRECTORY", // this enables customization of installation folder Description = rs.GetString("FeatAppDesc") }; // application data Feature datas = new Feature { Name = rs.GetString("FeatDataName"), Description = rs.GetString("FeatDataDesc") }; //documentation Feature docs = new Feature { Name = rs.GetString("FeatDocName"), Description = rs.GetString("FeatDocDesc") }; //shortcuts Feature shortcuts = new Feature { Name = rs.GetString("FeatShortcutName"), Description = rs.GetString("FeatShortcutDesc") }; // Prepare project Project project = new Project("LocalizationTest", //Files and Shortcuts new Dir(new Id("APPLICATIONROOTDIRECTORY"), @"%ProgramFiles%\LocalizationTest", // application binaries new File(binaries, @"AppFiles\Bin\MyApp.exe", new WixSharp.Shortcut(shortcuts, @"APPLICATIONROOTDIRECTORY"), new WixSharp.Shortcut(shortcuts, @"%Desktop%")), new File(binaries, @"AppFiles\Bin\MyApp.dll"), new WixSharp.Shortcut(binaries, "Uninstall Localization Test", "[System64Folder]msiexec.exe", "/x [ProductCode]"), // directory with application data new Dir("Data", new File(datas, @"AppFiles\Data\app_data.dat")), // directory with documentation new Dir("Doc", new File(docs, @"AppFiles\Docs\manual.txt"))), //program menu uninstall shortcut new Dir(@"%ProgramMenu%\Kosmii\KosmiiTest", new WixSharp.Shortcut(shortcuts, "Uninstall Kosmii Test", "[System64Folder]msiexec.exe", "/x [ProductCode]"))); // set project properties project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889a"); project.UpgradeCode = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); project.LicenceFile = @"AppFiles\License.rtf"; project.Language = lang; project.Encoding = System.Text.Encoding.UTF8; project.Manufacturer = Environment.UserName; project.UI = WUI.WixUI_Mondo; project.SourceBaseDir = Environment.CurrentDirectory; project.MSIFileName = "LocalizationTest"; Compiler.BuildMsi(project); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }
private static void Main(string[] args) { if (args.Length == 0) { throw new ArgumentNullException("Source"); } if (!File.Exists(args[0])) { throw new FileNotFoundException($"Source file not found: {args[0]}"); } string sourceFilename = args[0]; if (args.Length == 1) { throw new ArgumentNullException("Target"); } if (!File.Exists(args[1])) { throw new FileNotFoundException($"Target file not found: {args[1]}"); } string targetFilename = args[1]; var missingFilename = Path.GetFileNameWithoutExtension(targetFilename) + "-missing" + Path.GetExtension(targetFilename); var missingCount = 0; var foundCount = 0; using (var sourceReader = new ResXResourceReader(sourceFilename) { UseResXDataNodes = true }) { using (var targetSet = new ResXResourceSet(targetFilename)) { using (var missingWriter = new ResXResourceWriter(missingFilename)) { foreach (DictionaryEntry sourceEntry in sourceReader) { var targetEntry = targetSet.GetObject(sourceEntry.Key.ToString()); if (targetEntry == null) { missingCount++; Console.WriteLine($"Missing key: '{sourceEntry.Key}'"); missingWriter.AddResource((ResXDataNode)sourceEntry.Value); } else { foundCount++; } } } } } Console.WriteLine($"Found {foundCount}, missing {missingCount} out of {foundCount + missingCount} total keys."); if (missingCount == 0) { File.Delete(missingFilename); } else { Console.WriteLine($"File '{missingFilename}' generated with the missing keys."); } #if DEBUG Console.WriteLine("Hit any key to continue..."); Console.ReadKey(); #endif }
static void Main(String[] args) { //prepara la aplicación para que ejecute formularios y demás. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Idioma = ConfigurationManager.AppSettings["Idioma"]; textosLocal = new ResXResourceSet(@"./idiomas/" + "original." + Idioma + ".resx"); Log Log = Log.Instance; string versionNueva; if (HayActualizacions(out versionNueva)) { Log.ImprimirMensaje("Está disponible la actualización " + versionNueva, TipoMensaje.Info); DialogResult act = MessageBox.Show(textosLocal.GetString("actualizacion1") + Environment.NewLine + versionNueva + Environment.NewLine + textosLocal.GetString("actualizacion2"), "", MessageBoxButtons.YesNo); if (act == DialogResult.Yes) { Process.Start("https://github.com/orestescm76/aplicacion-gestormusica/releases"); } } if (args.Contains("-consola")) { AllocConsole(); Console.Title = "Consola debug v" + version; Console.WriteLine("Log creado " + DateTime.Now); Log.ImprimirMensaje("Se ha iniciado la aplicación con el parámetro -consola", TipoMensaje.Info); } miColeccion = new Coleccion(); configFileMap.ExeConfigFilename = Environment.CurrentDirectory + "/aplicacion_musica.exe.config"; config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); SpotifyActivado = false; principal = new principal(); if (!args.Contains("-noSpotify")) { if (config.AppSettings.Settings["VinculadoConSpotify"].Value == "false") { _spotify = new Spotify(false); } else { _spotify = new Spotify(true); SpotifyActivado = true; principal.DesactivarVinculacion(); } } else { SpotifyActivado = false; Log.ImprimirMensaje("Se ha iniciado la aplicación con el parámetro -noSpotify, no habrá integración con Spotify", TipoMensaje.Info); _spotify = null; principal.HayInternet(false); } if (args.Contains("-modoStream")) { ModoStream = true; Log.ImprimirMensaje("Iniciando modo Stream", TipoMensaje.Info); } Reproductor reproductor = Reproductor.Instancia; if (!ModoStream) { Log.ImprimirMensaje("Configurando géneros", TipoMensaje.Info); for (int i = 0; i < idGeneros.Length; i++) { if (idGeneros[i] == "") { generos[i] = new Genero(idGeneros[i]); generos[i].setTraduccion("-"); } else { generos[i] = new Genero(idGeneros[i]); generos[i].setTraduccion(textosLocal.GetString("genero_" + generos[i].Id)); } } if (args.Contains("-json")) { cargarAlbumes("discos.json"); } else { if (File.Exists("discos.csv")) { cargarAlbumesCSV("discos.csv"); cargarCDS(); } else { Log.ImprimirMensaje("discos.csv no existe, se creará una base de datos vacía.", TipoMensaje.Advertencia); } } if (File.Exists("paths.txt")) { CargarPATHS(); } } //creo el Reproductor Reproductor.Instancia = new Reproductor(); Reproductor.Instancia.RefrescarTextos(); if (ModoStream) //enchufa la app sin nada, solo el spotify y el texto { Application.Run(); } else if (!args.Contains("-reproductor")) //tirale con el principal { Application.Run(principal); } else { ModoReproductor = true; Application.Run(Reproductor.Instancia); //Reproductor.Instancia.Show(); } if (_spotify != null && tareaRefrescoToken != null) { tareaRefrescoToken.Abort(); } if (!ModoStream) { GuardarPATHS(); } config.AppSettings.Settings["Idioma"].Value = Idioma; config.Save(); if (File.Exists("./covers/np.jpg")) { try { File.Delete("./covers/np.jpg"); } catch (IOException) { Log.ImprimirMensaje("No se ha podido eliminar el fichero np.jpg.", TipoMensaje.Advertencia); } } if (args.Contains("-consola")) { Console.WriteLine("Programa finalizado, presione una tecla para continuar..."); Console.ReadKey(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["role"] == null) { Response.Redirect("Login.aspx"); } if (Session["role"].ToString() == "Developer") { lblDevs.Text = "Welcome " + Session["role"] + "!"; int notnumberdev; notnumberdev = CountNotificationNumberDev(); LabelNotNumber.Text = notnumberdev.ToString() + " new comments"; FillGridWiew1(); FillGridWiew2(); ResXResourceSet resxSet = new ResXResourceSet(Server.MapPath("~/StringResources/Resource.resx")); ResLabel1.Text = resxSet.GetString("String1"); ResLabel2.Text = resxSet.GetString("String2"); ResLabel3.Text = resxSet.GetString("String3"); ResLabel4.Text = resxSet.GetString("String4"); ResLabel5.Text = resxSet.GetString("String5"); ResLabel6.Text = resxSet.GetString("String6"); ResLabel7.Text = resxSet.GetString("String7"); ResLabel8.Text = resxSet.GetString("String6"); ResLabel9.Text = resxSet.GetString("String11"); ResLabel10.Text = resxSet.GetString("String6"); ResLabel11.Text = resxSet.GetString("String12"); ResLabel12.Text = resxSet.GetString("String6"); if (GridView1.Rows.Count == 0) { Labelhiden1.Visible = true; } if (GridView2.Rows.Count == 0) { Labelhiden2.Visible = true; } } else { lblTrans.Text = "Welcome " + Session["role"] + "!"; int notnumbertran; notnumbertran = CountNotificationNumberTrans(); LabeNotNumberTrans.Text = notnumbertran.ToString() + " new comments"; FillGridWiew3(); FillGridWiew4(); ResXResourceSet resxSet = new ResXResourceSet(Server.MapPath("~/StringResources/Resource.resx")); ResLabelTrans1.Text = resxSet.GetString("String8"); ResLabelTrans2.Text = resxSet.GetString("String9"); ResLabelTrans3.Text = resxSet.GetString("String10"); if (GridView3.Rows.Count == 0) { Labelhiden3.Visible = true; } if (GridView4.Rows.Count == 0) { Labelhiden4.Visible = true; } } } }
// -------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Puts all saved games to the table /// </summary> private void ShowSavedGamesTranslation(ResXResourceSet resSet) { // Show all saved Games int rowNr = 1; foreach (PAPIGame game in _savedGames) { if (_shownGames.Contains(game)) { continue; } WfLogger.Log(this, LogLevel.DEBUG, "Added game to list of saved games: " + game._genre + ", " + game._dateOfLastSession.ToString()); // Add Genre gameTable.Controls.Add(new Label() { Text = TranslatedString(resSet, "genre_" + _savedGames[rowNr - 1]._genre.ToString().ToLower()), Anchor = AnchorStyles.Left | AnchorStyles.Top, Width = 250 }, 0, rowNr); // Date of creation label gameTable.Controls.Add(new Label() { Text = game._dateOfCreation.ToShortDateString(), Anchor = AnchorStyles.Left | AnchorStyles.Top, }, 1, rowNr); // Date of last save label gameTable.Controls.Add(new Label() { Text = game._dateOfLastSession.ToShortDateString(), Anchor = AnchorStyles.Left | AnchorStyles.Top, }, 2, rowNr); // Add show Game Button to current row Button showGameBtn = new Button() { Text = "", FlatStyle = FlatStyle.Flat, Anchor = AnchorStyles.Right | AnchorStyles.Top, Size = new Size(40, 40), Name = "load_game_button_" + rowNr }; string imagePath = GameDirectory.GetFilePath_Images(PAPIApplication.GetDesign()) + "\\show.bmp"; Image image = Image.FromFile(imagePath); showGameBtn.Image = (Image)(new Bitmap(image, new Size(40, 40))); _gameButtons.Add(game, showGameBtn); gameTable.Controls.Add(showGameBtn, 2, rowNr++); _buttons.Add(showGameBtn); _shownGames.Add(game); } // Set size of each row to same foreach (RowStyle rowStyle in gameTable.RowStyles) { rowStyle.SizeType = SizeType.Absolute; rowStyle.Height = 44; } _buttons.Add(return_button); _buttons.Add(game_creator_button); SetButtonDesign(); // Add eventhandler for click on every show game button foreach (KeyValuePair <PAPIGame, Button> button in _gameButtons) { button.Value.Click += Load_Game_Button_Click; } }
public static void LoadStrings() { var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = config.AppSettings.Settings; var TargetCode = settings["language"].Value; //to powinno dać jaki język aplikacji ma być config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name); var directory = Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).ToString()) + $"\\Languages\\{TargetCode}.resx"; if (!File.Exists(directory)) { MessageBox.Show("Something went wrong and the language file doesn't exist! Resetting to default. Please try changing " + "the language again."); TargetCode = "pl"; // settings["language"].Value = TargetCode; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name); } else { //var manager = new ResourceManager("AlgorytmySzkolne.Languages." + TargetCode, Assembly.GetExecutingAssembly()); using (var manager = new ResXResourceSet(directory)) { //nie wiem jak z performance strGlowna = manager.GetString("strGlowna"); strInfo = manager.GetString("strInfo"); strKlasyczne = manager.GetString("strKlasyczne"); strZachlanne = manager.GetString("strZachlanne"); strSystemy = manager.GetString("strSystemy"); strONP = manager.GetString("strONP"); strProjekty = manager.GetString("strProjekty"); strAproksymacja = manager.GetString("strAproksymacja"); strEuklides = manager.GetString("strEuklides"); strSilnia = manager.GetString("strSilnia"); strPierwsza = manager.GetString("strPierwsza"); strSumaDzielnikow = manager.GetString("strSumaDzielnikow"); strCzynnikiPierwsze = manager.GetString("strCzynnikiPierwsze"); strSumaPrzedzialu = manager.GetString("strSumaPrzedzialu"); strSumaCyfr = manager.GetString("strSumaCyfr"); strRNG = manager.GetString("strRNG"); strUstaw = manager.GetString("strUstaw"); strZerowe = manager.GetString("strZerowe"); strPierwiastek = manager.GetString("strPierwiastek"); strPierwiastek2 = manager.GetString("strPierwiastek2"); strCalka = manager.GetString("strCalka"); strCalka2 = manager.GetString("strCalka2"); oWartosc = manager.GetString("oWartosc"); oNaONP = manager.GetString("oNaONP"); oZONP = manager.GetString("oZONP"); fWielomian = manager.GetString("fWielomian"); fWymierna = manager.GetString("fWymierna"); fPierwiastek = manager.GetString("fPierwiastek"); fSin = manager.GetString("fSin"); fCos = manager.GetString("fCos"); fTg = manager.GetString("fTg"); fCtg = manager.GetString("fCtg"); fLosuj = manager.GetString("fLosuj"); fAlternatywa = manager.GetString("fAlternatywa"); aX = manager.GetString("aX"); aPI = manager.GetString("aPI"); aWynik = manager.GetString("aWynik"); aLiczba = manager.GetString("aLiczba"); aDzielnik = manager.GetString("aDzielnik"); aWielokrotność = manager.GetString("aWielokrotność"); aPierwsza = manager.GetString("aPierwsza"); aCzynniki = manager.GetString("aCzynniki"); aPrzedział = manager.GetString("aPrzedział"); tAlgorytmySzkolne = manager.GetString("tAlgorytmySzkolne"); tAproksymacja = manager.GetString("tAproksymacja"); tSierpiński = manager.GetString("tSierpiński"); tHetmani = manager.GetString("tHetmani"); tSkoczek = manager.GetString("tSkoczek"); tWykres = manager.GetString("tWykres"); strCzyChceszWyjść = manager.GetString("strCzyChceszWyjść"); strWyjście = manager.GetString("strWyjście"); strPodajArgument = manager.GetString("strPodajArgument"); strPodajEpsilon = manager.GetString("strPodajEpsilon"); strPodajIloscOdcinkow = manager.GetString("strPodajIloscOdcinkow"); strPodajLiczbę = manager.GetString("strPodajLiczbę"); strPodajLiczbę1 = manager.GetString("strPodajLiczbę1"); strPodajLiczbę2 = manager.GetString("strPodajLiczbę2"); strPrzedział1 = manager.GetString("strPrzedział1"); strPrzedział2 = manager.GetString("strPrzedział2"); strGranica1 = manager.GetString("strGranica1"); strGranica2 = manager.GetString("strGranica2"); strRestart = manager.GetString("strRestart"); strInfo1 = manager.GetString("strInfo1"); strInfo2_1 = manager.GetString("strInfo2_1"); strInfo2_2 = manager.GetString("strInfo2_2"); strInfo2_3 = manager.GetString("strInfo2_3"); iOstrzeżenie = manager.GetString("iOstrzeżenie"); iNiepewne = manager.GetString("iNiepewne"); iTypFunkcji = manager.GetString("iTypFunkcji"); iFunkcja = manager.GetString("iFunkcja"); iNWD = manager.GetString("iNWD"); iSilnia = manager.GetString("iSilnia"); iPierwsza = manager.GetString("iPierwsza"); iSumaDzielników = manager.GetString("iSumaDzielników"); iCzynnikiPierwsze = manager.GetString("iCzynnikiPierwsze"); iSumaPrzedziału = manager.GetString("iSumaPrzedziału"); iSumaCyfr = manager.GetString("iSumaCyfr"); iRNG = manager.GetString("iRNG"); iZerowe = manager.GetString("iZerowe"); iCałka = manager.GetString("iCałka"); iPierwiastek = manager.GetString("iPierwiastek"); iONPWartość = manager.GetString("iONPWartość"); iONPZ = manager.GetString("iONPZ"); iONPNa = manager.GetString("iONPNa"); iFWielomian = manager.GetString("iFWielomian"); iFWymierna = manager.GetString("iFWymierna"); iFPierwiastek = manager.GetString("iFPierwiastek"); iFLosuj = manager.GetString("iFLosuj"); iFTrygonometrycznaX = manager.GetString("iFTrygonometrycznaX"); iFTrygonometrycznaPI = manager.GetString("iFTrygonometrycznaPI"); iPodajWspółczynniki = manager.GetString("iPodajWspółczynniki"); pArgument = manager.GetString("pArgument"); pOblicz = manager.GetString("pOblicz"); pWykonaj = manager.GetString("pWykonaj"); eBłąd = manager.GetString("eBłąd"); eBłądStopnia = manager.GetString("eBłądStopnia"); eSukces = manager.GetString("eSukces"); eWylosowano = manager.GetString("eWylosowano"); eUstawiono = manager.GetString("eUstawiono"); eNieZnaleziono = manager.GetString("eNieZnaleziono"); emsgBłądArgumentu = manager.GetString("emsgBłądArgumentu"); emsgNiePodanoFunkcji = manager.GetString("emsgNiePodanoFunkcji"); emsgBłądFunkcji = manager.GetString("emsgBłądFunkcji"); emsgFormatWejścia = manager.GetString("emsgFormatWejścia"); emsgPodstawaSystemu = manager.GetString("emsgPodstawaSystemu"); emsgException = manager.GetString("emsgException"); emsgAproksymacjaPunkty = manager.GetString("emsgAproksymacjaPunkty"); emsgSierpinskiPoziomy = manager.GetString("emsgSierpinskiPoziomy"); emsgIlośćOdcinków = manager.GetString("emsgIlośćOdcinków"); emsgNieprawidłowyStopień = manager.GetString("emsgNieprawidłowyStopień"); emsgStopieńLosowejFunkcji = manager.GetString("emsgStopieńLosowejFunkcji"); emsgNiepoprawnyWspółczynnikFunkcji = manager.GetString("emsgNiepoprawnyWspółczynnikFunkcji"); emsgTranslacjaNieDziała = manager.GetString("emsgTranslacjaNieDziała"); hIlośćH = manager.GetString("hIlośćH"); hIlośćS = manager.GetString("hIlośćS"); hFailH = manager.GetString("hFailH"); hFailS = manager.GetString("hFailS"); hNieMożnaH = manager.GetString("hNieMożnaH"); hNieMożnaS = manager.GetString("hNieMożnaS"); hGratulacjeH = manager.GetString("hGratulacjeH"); hGratulacjeS = manager.GetString("hGratulacjeS"); hRestart = manager.GetString("hRestart"); bKlasyczne = manager.GetString("bKlasyczne"); bZachlanne = manager.GetString("bZachlanne"); bSystemy = manager.GetString("bSystemy"); bONP = manager.GetString("bONP"); bProjekty = manager.GetString("bProjekty"); bSPOJ = manager.GetString("bSPOJ"); bNWD = manager.GetString("bNWD"); bSilnia = manager.GetString("bSilnia"); bLiczbaPierwsza = manager.GetString("bLiczbaPierwsza"); bSumaDzielników = manager.GetString("bSumaDzielników"); bRozkład = manager.GetString("bRozkład"); bSumaPrzedziału = manager.GetString("bSumaPrzedziału"); bSumaCyfr = manager.GetString("bSumaCyfr"); bRNG = manager.GetString("bRNG"); bUstawFunkcję = manager.GetString("bUstawFunkcję"); bPokażFunkcję = manager.GetString("bPokażFunkcję"); bPodajStopień = manager.GetString("bPodajStopień"); bPodajStopieńFunkcji = manager.GetString("bPodajStopieńFunkcji"); bPodajStopieńPierwiastka = manager.GetString("bPodajStopieńPierwiastka"); bPodajStopieńLicznika = manager.GetString("bPodajStopieńLicznika"); bPodajStopieńMianownika = manager.GetString("bPodajStopieńMianownika"); bWybierzFunkcję = manager.GetString("bWybierzFunkcję"); bMiejsceZerowe = manager.GetString("bMiejsceZerowe"); bPierwiastekKwadratowy = manager.GetString("bPierwiastekKwadratowy"); bCałka = manager.GetString("bCałka"); bAproksymacja = manager.GetString("bAproksymacja"); bSierpiński = manager.GetString("bSierpiński"); bHetmani = manager.GetString("bHetmani"); bSkoczek = manager.GetString("bSkoczek"); bWykres = manager.GetString("bWykres"); bSystemZKtórego = manager.GetString("bSystemZKtórego"); bSystemNaKtóry = manager.GetString("bSystemNaKtóry"); bSystemPodaj = manager.GetString("bSystemPodaj"); bWybierzArgument = manager.GetString("bWybierzArgument"); bWybierzTypArgumentu = manager.GetString("bWybierzTypArgumentu"); bKopiuj = manager.GetString("bKopiuj"); bUstaw = manager.GetString("bUstaw"); bPrzykład = manager.GetString("bPrzykład"); bWybierzAlgorytm = manager.GetString("bWybierzAlgorytm"); bDokładność = manager.GetString("bDokładność"); bPokaż = manager.GetString("bPokaż"); bPoziomy = manager.GetString("bPoziomy"); } } }
static public void Main(string[] args) { try { string lang = "cs-CZ"; // determine language localization //get access to CLR resource file var resPath = "Resource." + lang + ".resx"; // path to resource if buildинг from command prompt if (!System.IO.File.Exists(resPath)) { Environment.CurrentDirectory = @"..\..\"; // path to resource if buildинг from Visual Studio } var rs = new ResXResourceSet(resPath); //Prepare features // binaries Feature binaries = new Feature { Name = rs.GetString("FeatAppName"), ConfigurableDir = "APPLICATIONROOTDIRECTORY", // this enables customization of installation folder Description = rs.GetString("FeatAppDesc") }; // application data Feature datas = new Feature { Name = rs.GetString("FeatDataName"), Description = rs.GetString("FeatDataDesc") }; //documentation Feature docs = new Feature { Name = rs.GetString("FeatDocName"), Description = rs.GetString("FeatDocDesc") }; //shortcuts Feature shortcuts = new Feature { Name = rs.GetString("FeatShortcutName"), Description = rs.GetString("FeatShortcutDesc") }; // Prepare project Project project = new Project("LocalizationTest", //Files and Shortcuts new Dir(new Id("APPLICATIONROOTDIRECTORY"), @"%ProgramFiles%\LocalizationTest", // application binaries new File(binaries, @"AppFiles\Bin\MyApp.exe", new WixSharp.Shortcut(shortcuts, @"APPLICATIONROOTDIRECTORY"), new WixSharp.Shortcut(shortcuts, @"%Desktop%")), new File(binaries, @"AppFiles\Bin\MyApp.dll"), new WixSharp.Shortcut(binaries, "Uninstall Localization Test", "[System64Folder]msiexec.exe", "/x [ProductCode]"), // directory with application data new Dir("Data", new File(datas, @"AppFiles\Data\app_data.dat")), // directory with documentation new Dir("Doc", new File(docs, @"AppFiles\Docs\manual.txt"))), //program menu uninstall shortcut new Dir(@"%ProgramMenu%\Kosmii\KosmiiTest", new WixSharp.Shortcut(shortcuts, "Uninstall Kosmii Test", "[System64Folder]msiexec.exe", "/x [ProductCode]"))); // set project properties project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889a"); project.UpgradeCode = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); project.LicenceFile = @"AppFiles\License.rtf"; project.Language = lang; project.Encoding = System.Text.Encoding.UTF8; project.Manufacturer = Environment.UserName; project.UI = WUI.WixUI_Mondo; project.SourceBaseDir = Environment.CurrentDirectory; project.MSIFileName = "LocalizationTest"; Compiler.BuildMsi(project); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }
public void Save() { var path = Path.GetTempPath(); var rs = new ResXResourceSet(basePath: path) { SafeMode = true }; var newFile = Path.GetTempFileName(); rs.SetObject("fileref", new ResXFileRef(newFile, typeof(string))); var filerefRef = ((ResXDataNode)rs.GetObject("fileref")).FileRef; Assert.IsTrue(Path.IsPathRooted(filerefRef.FileName)); var sb = new StringBuilder(); rs.Save(new StringWriter(sb)); // path does not change in original resource set after saving Assert.IsTrue(Path.IsPathRooted(filerefRef.FileName)); // if BasePath was specified, the path turns relative on saving var rsReloaded = new ResXResourceSet(new StringReader(sb.ToString()), path) { SafeMode = true }; var filerefCheck = ((ResXDataNode)rsReloaded.GetObject("fileref")).FileRef; Assert.IsFalse(Path.IsPathRooted(filerefCheck.FileName)); // fileref paths are adjusted if BasePath is changed, even the original relative paths sb = new StringBuilder(); string newPath = Path.Combine(path, "subdir"); rsReloaded.Save(new StringWriter(sb), newBasePath: newPath); rsReloaded = new ResXResourceSet(new StringReader(sb.ToString())) { SafeMode = true }; var filerefCheck2 = ((ResXDataNode)rsReloaded.GetObject("fileref")).FileRef; Assert.AreNotEqual(filerefCheck.FileName, filerefCheck2.FileName); // on forced embedding the fileRefs are gone sb = new StringBuilder(); rs.Save(new StringWriter(sb), forceEmbeddedResources: true); rsReloaded = new ResXResourceSet(new StringReader(sb.ToString())) { SafeMode = true }; Assert.IsNull(((ResXDataNode)rsReloaded.GetObject("fileref")).FileRef); // creating without basePath... rs = new ResXResourceSet { SafeMode = true }; rs.SetObject("filerefFull", new ResXFileRef(newFile, typeof(string))); rs.SetObject("filerefRelative", new ResXFileRef(Path.GetFileName(newFile), typeof(string))); // neither original, nor new basePath: all paths remain as it is sb = new StringBuilder(); rs.Save(new StringWriter(sb)); rsReloaded = new ResXResourceSet(new StringReader(sb.ToString())) { SafeMode = true }; Assert.AreEqual(((ResXDataNode)rs.GetObject("filerefFull")).FileRef.FileName, ((ResXDataNode)rsReloaded.GetObject("filerefFull")).FileRef.FileName); Assert.AreEqual(((ResXDataNode)rs.GetObject("filerefRelative")).FileRef.FileName, ((ResXDataNode)rsReloaded.GetObject("filerefRelative")).FileRef.FileName); // no original basePath just a new one: the relative paths are not changed, full paths become relative sb = new StringBuilder(); rs.Save(new StringWriter(sb), newBasePath: path); rsReloaded = new ResXResourceSet(new StringReader(sb.ToString())) { SafeMode = true }; Assert.AreNotEqual(((ResXDataNode)rs.GetObject("filerefFull")).FileRef.FileName, ((ResXDataNode)rsReloaded.GetObject("filerefFull")).FileRef.FileName); Assert.IsFalse(Path.IsPathRooted(((ResXDataNode)rsReloaded.GetObject("filerefFull")).FileRef.FileName)); Assert.AreEqual(((ResXDataNode)rs.GetObject("filerefRelative")).FileRef.FileName, ((ResXDataNode)rsReloaded.GetObject("filerefRelative")).FileRef.FileName); File.Delete(newFile); }