public void Save(System.IO.TextWriter stream)
        {
            RemoveDuplicateElements();
            var ms = new MemoryStream();

            doc.Save(ms);
            ms.Flush();
            ms.Position = 0;
            var s = new StreamReader(ms).ReadToEnd();

            if (ApplicationName != null)
            {
                s = s.Replace("${applicationId}", ApplicationName);
            }
            if (Placeholders != null)
            {
                foreach (var entry in Placeholders.Select(e => e.Split(new char [] { '=' }, 2, StringSplitOptions.None)))
                {
                    if (entry.Length == 2)
                    {
                        s = s.Replace("${" + entry [0] + "}", entry [1]);
                    }
                    else
                    {
                        log.LogWarning("Invalid application placeholders (AndroidApplicationPlaceholders) value. Use 'key1=value1;key2=value2, ...' format. The specified value was: " + Placeholders);
                    }
                }
            }
            stream.Write(s);
        }
示例#2
0
        public override async Task <bool> ExecuteAsync(IProgress <string> progress, StepContext ctx)
        {
            if (!IsTargetDirectoryValid(ctx))
            {
                return(false);
            }

            var placeholders = Placeholders.Select(p => new KeyValuePair <string, string>(p.TextToReplace, p.Replacement)).ToArray();

            progress.Report("Replacing placeholders in file names and directories...");

            await Task.Run(() => IOHelper.ReplacePlaceholdersInFileNamesAndDirectories(ctx.TargetDirectory, placeholders));

            progress.Report("Replacing placeholders in file content...");

            await Task.Run(() => IOHelper.ReplacePlaceholdersInFilesContent(ctx.TargetDirectory, placeholders));

            progress.Report("Replacing guids in file content...");

            await Task.Run(() => IOHelper.ReplaceGuids(ctx.TargetDirectory));

            return(true);
        }