Exemple #1
0
        public void TestUnderscores()
        {
            Assert.That(Underscores.Transform(string.Empty), Is.EqualTo(string.Empty));
            var message = "hello, world!";

            Assert.That(Underscores.Transform(message), Is.EqualTo(new string('_', message.Length)));
        }
Exemple #2
0
        private void ProcessResxFile(string inputFileName)
        {
            try
            {
                var outputFileName = Path.Combine(Path.GetDirectoryName(inputFileName), Path.GetFileNameWithoutExtension(inputFileName) + ".qps-ploc" + Path.GetExtension(inputFileName));

                using (var inputStream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read))
                    using (var outputStream = new FileStream(outputFileName, FileMode.Create, FileAccess.Write))
                    {
                        var processor = new ResxProcessor();
                        if (EnableExtraLength || UseDefaultOptions)
                        {
                            processor.TransformString += (s, e) => { e.Value = ExtraLength.Transform(e.Value); };
                        }

                        if (EnableAccents || UseDefaultOptions)
                        {
                            processor.TransformString += (s, e) => { e.Value = Accents.Transform(e.Value); };
                        }

                        if (EnableBrackets || UseDefaultOptions)
                        {
                            processor.TransformString += (s, e) => { e.Value = Brackets.Transform(e.Value); };
                        }

                        if (EnableMirror)
                        {
                            processor.TransformString += (s, e) => { e.Value = Mirror.Transform(e.Value); };
                        }

                        if (EnableUnderscores)
                        {
                            processor.TransformString += (s, e) => { e.Value = Underscores.Transform(e.Value); };
                        }

                        processor.Transform(inputStream, outputStream);
                    }

                Console.WriteLine("The file {0} was written successfully.", outputFileName);
            }
            catch (Exception ex)
            {
                if (ex is PathTooLongException ||
                    ex is FileNotFoundException ||
                    ex is DirectoryNotFoundException ||
                    ex is IOException ||
                    ex is SecurityException)
                {
                    Console.WriteLine(ex.Message);
                }
                else
                {
                    throw;
                }
            }
        }