private static void TranslateFile(ResourceFile resourceFile, string outputFilename) { if (resourceFile.EntriesToTranslate.Count > 0 || (resourceFile.IncludeAllEntries && resourceFile.EntriesUntranslated.Count > 0)) { ResXResourceWriter writer = new ResXResourceWriter(outputFilename); if (resourceFile.EntriesToTranslate.Count > 0) { var resourceGroups = GetGroups(resourceFile, resourceFile.EntriesToTranslate); foreach (var resourceGroup in resourceGroups) { TranslateGroup(resourceFile, writer, resourceGroup); } } if (resourceFile.IncludeAllEntries && resourceFile.EntriesUntranslated.Count > 0) { foreach (var entry in resourceFile.EntriesUntranslated) { writer.AddResource(entry.Key, entry.OriginalValue); } } writer.Generate(); writer.Dispose(); } }
private void BorrarRecursos() { using (ResXResourceWriter resxWriter = new ResXResourceWriter(ObtenerPathRecursos())) { resxWriter.Dispose(); } }
public System.Resources.IResourceWriter GetResourceWriter(System.Globalization.CultureInfo info) { //ResXResourceWriter writer = (ResXResourceWriter) writers[info]; if (writer != null) { //writer.Generate(); //writer.Close(); writer.Dispose(); } writer = new ResXResourceWriter(path); // if (writer == null) // { // writer = new ResXResourceWriter(path); // //writers.Add(info, writer); // } return(writer); }
public void Save() { // Create a ResXResourceReader for the file items.resx. ResXResourceReader rsxr = new ResXResourceReader(path); ResXResourceWriter rsxTranslated = new ResXResourceWriter(path + "_2"); // Create an IDictionaryEnumerator to iterate through the resources. IDictionaryEnumerator id = rsxr.GetEnumerator(); // Iterate through the resources foreach (DictionaryEntry d in rsxr) { rsxTranslated.AddResource(d.Key.ToString(), d.Value); } rsxTranslated.Generate(); rsxTranslated.Close(); rsxTranslated.Dispose(); }
private async void button9_Click(object sender, EventArgs e) { try { if (!(pictureBox3.Image.Equals(null))) { ResXResourceWriter resX = new ResXResourceWriter(Resources.ResourceManager.BaseName); byte[] _byteArr = await ImageToByteAsync(pictureBox3.Image); resX.AddResource("resource1", _byteArr); resX.Generate(); resX.Close(); resX.Dispose(); resX = null; } textBox1.AppendText($"pic added to Resources{Environment.NewLine}"); } catch (Exception exc) { textBox1.AppendText($"pic not added to res => {exc.ToString()}{Environment.NewLine}"); } }
internal static void YouDied() { // GameController.Save(); //挂前存个档 var incursionDetect = DateTime.Now; Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Red; var random = new Random(); Console.SetWindowSize(120, 30); var isWritten = new bool[Console.WindowWidth / 2, Console.WindowHeight]; for (var i = 0; i < Console.WindowHeight; i++) { for (var j = 0; j < Console.WindowWidth / 2; j++) { int h; int w; do { h = random.Next(Console.WindowHeight); w = random.Next(Console.WindowWidth / 2); } while (isWritten[w, h]); Console.SetCursorPosition(w * 2, h); Console.Write(random.Next(2) + @" "); isWritten[w, h] = true; } Thread.Sleep(100); } var failSave = DateTime.Now; GameController.Save(); if (File.Exists(@".\Save.resx") && !File.Exists(@".\Save.bak")) { File.Move(@".\Save.resx", @".\Save.bak"); } using var resx = new ResXResourceWriter(@".\Save.resx"); resx.AddResource("RootKit", "BootUpHijacking"); resx.Dispose(); var asciiLength = 0; var calculateAsciiTask = Task.Run(() => { asciiLength = BigFirework_TextResource.YouDied.Replace("\r\n", "\n").Split('\n') .Select(str => str.Length).Concat(new[] { asciiLength }).Max(); }); Thread.Sleep(2000); calculateAsciiTask.Wait(); var basicTPos = 5; foreach (var str in BigFirework_TextResource.YouDied.Replace("\r\n", "\n").Split('\n')) { Console.SetCursorPosition((Console.WindowWidth - asciiLength) / 2, basicTPos); Console.Write(str); basicTPos++; } basicTPos++; Console.SetCursorPosition((Console.WindowWidth - asciiLength) / 2, basicTPos); Console.Write(string.Empty.PadLeft(asciiLength, '#')); basicTPos += 2; Console.SetCursorPosition((Console.WindowWidth - asciiLength) / 2, basicTPos); Console.Write(string.Empty.PadLeft(asciiLength, '#')); Console.ResetColor(); Thread.Sleep(1000); var freesia = DateTime.Now; using (var fileStream = new FileStream(@".\log.txt", FileMode.Append)) { using (var streamWriter = new StreamWriter(fileStream)) { streamWriter.Write(BigFirework_TextResource.FailedLog, incursionDetect, failSave, freesia); streamWriter.Flush(); } } Environment.Exit(0); }
public byte[] GenerateResx(string codeNamespace, MessageData messages, string className) { byte[] results = null; MemoryStream stream = null; ResXResourceWriter writer = null; try { stream = new MemoryStream(); writer = new ResXResourceWriter(stream); // Add the messages... foreach (Message message in messages.Messages) { foreach (Instance instance in message.Instances) { ResXDataNode node = new ResXDataNode( string.Concat(className, ".", instance.Name), instance.Message); // Add comments if there are params... if (instance.ParameterList != null && instance.ParameterList.Count > 0) { StringBuilder builder = new StringBuilder(); builder.Append("params: "); foreach (var param in instance.ParameterList) { builder.AppendFormat("[{1}]{0}, ", param.Item1, param.Item2.Name); } // remove the trailing ", "... builder.Length -= 2; node.Comment = builder.ToString(); } writer.AddResource(node); } } writer.Generate(); results = stream.ToArray(); stream = null; } finally { if (writer != null) { // stream will be disposed by the writer... stream = null; writer.Dispose(); writer = null; } if (stream != null) { stream.Dispose(); stream = null; } } return(results); }