private void ExecuteCore() {
            ResXCodeBuilder codeBuilder = new ResXCodeBuilder();

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

                codeBuilder.GenerateCode(resourceFileName, resourceContent, resourceGenerator);
            }

            string code = codeBuilder.End();

            File.WriteAllText(_generatedCode.ItemSpec, code);
        }
示例#2
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, null);
            string code1 = resxCodeBuilder.End();

            resxCodeBuilder.Start("Resources");
            resxCodeBuilder.GenerateCode("Strings2.resx", resource2Markup, "PublicResxScriptGenerator");
            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" };
            });
        }