Ejemplo n.º 1
0
        public void TestResources()
        {
            string resource1Path = GetTestFilePath("Strings1.resx");
            string resource2Path = GetTestFilePath("Strings2.resx");

            string resource1Markup = File.ReadAllText(resource1Path);
            string resource2Markup = File.ReadAllText(resource2Path);

            ResXCodeBuilder resxCodeBuilder = new ResXCodeBuilder();

            resxCodeBuilder.Start("Resources");
            resxCodeBuilder.GenerateCode("Strings1.resx", resource1Markup);
            string code1 = resxCodeBuilder.End();

            resxCodeBuilder.Start("Resources");
            resxCodeBuilder.GenerateCode("Strings2.resx", resource2Markup);
            string code2 = resxCodeBuilder.End();

            RunTest((c) => {
                c.AddSource("Code.cs").
                AddCode("Strings1.Designer.cs", code1).
                AddCode("Strings2.Designer.cs", code2).
                AddResource("Strings1.resx").
                AddResource("Strings1.fr.resx").
                AddResource("Strings1.fr-FR.resx").
                AddResource("Strings2.resx");
                c.Options.DebugFlavor = true;
                c.Options.Defines     = new string[] { "DEBUG" };
            });
        }
Ejemplo n.º 2
0
        private void ExecuteCore()
        {
            ResXCodeBuilder codeBuilder = new ResXCodeBuilder();

            codeBuilder.Start(_namespace);
            foreach (ITaskItem resourceItem in _resources)
            {
                string resourceFileName = resourceItem.ItemSpec;
                string resourceContent  = File.ReadAllText(resourceFileName);

                codeBuilder.GenerateCode(resourceFileName, resourceContent);
            }

            string code = codeBuilder.End();

            File.WriteAllText(_generatedCode.ItemSpec, code);
        }