Exemplo n.º 1
0
        // originally taken from http://stackoverflow.com/a/16987412/124069
        public void WriteToTarget(ProjectModel project, IDictionary<string, string> strings, FileInfo sourceFile)
        {
            var targetDir = Path.Combine(project.ProjectPath, "resources/values/");
            var resourceType = sourceFile.GetResourceType();
            var builder = new StringBuilder();

            builder.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            builder.Append(@"
            <!-- ..........................................................................
            <auto-generated>
            This code was generated by a tool.
            Runtime Version:" + Helpers.GetAssemblyVersion() + @" (ResourceMigrator.exe)

            Changes to this file may cause incorrect behavior and will be lost if
            the code is regenerated.
            </auto-generated>
             ........................................................................... -->
            ");

            builder.AppendLine("<resources>");

            foreach (var key in strings.Keys)
            {
                builder.Append("    ");
                builder.AppendLine(string.Format("<{0} name=\"{1}\">{2}</{0}>", resourceType, key, strings[key].ToEscapedString()));
            }

            builder.AppendLine("</resources>");

            var outputFileName = Path.GetFileNameWithoutExtension(sourceFile.Name) + ".xml";
            File.WriteAllText(Path.Combine(targetDir, outputFileName), builder.ToString());
        }
Exemplo n.º 2
0
        public void WriteToTarget(ProjectModel project, IDictionary<string, string> strings, FileInfo sourceFile)
        {
            _targetDir = Path.Combine(project.ProjectPath, "resources/");
            _strings = strings;
            _touchNameSpace = project.ProjectNamespace + ".Resources";

            var resourceType = sourceFile.GetResourceType();
            if (resourceType == "color")
            {
                BuildColorResourceForTouch();
            }
        }