private static void SetField(TocFile file, string name, string value) { if (!String.IsNullOrEmpty(value)) { file[name] = value; } }
public override bool Execute() { TocFile tf = new TocFile(); // The file might not exist, if the project has no TOC files and a TOC entry was dynamically generated if (File.Exists(this.InputPath.ItemSpec)) { using (TextReader r = new StreamReader(this.InputPath.ItemSpec, Encoding.UTF8, true)) { tf.Read(r); } } using (TextWriter w = new StreamWriter(this.OutputPath.ItemSpec, false, Encoding.UTF8)) { if (!IsFieldSet(tf, "X-AutoGenerated")) { SetField(tf, "X-AutoGenerated", "true"); } if (!IsFieldSet(tf, "X-GeneratorComment")) { SetField(tf, "X-GeneratorComment", generatorComment); } SetField(tf, "Interface", this.InterfaceVersion); SetField(tf, "Title", this.AddonTitle); SetField(tf, "Notes", this.AddonNotes); SetField(tf, "Dependencies", this.Dependencies); SetField(tf, "SavedVariables", this.SavedVariables); SetField(tf, "SavedVariablesPerCharacter", this.SavedVariablesPerCharacter); SetField(tf, "Author", this.Author); SetField(tf, "Version", this.AddonVersion); SetField(tf, "X-eMail", this.AuthorEmail); tf.Files.Clear(); if (this.Files != null) { foreach (ITaskItem item in this.Files) { tf.Files.Add(item.ItemSpec); } } tf.Write(w); } return(true); }
private static void SetField(TocFile file, string name, string value) { if (!String.IsNullOrEmpty(value)) file[name] = value; }
private static bool IsFieldSet(TocFile file, string name) { return file[name] != null; }
public override bool Execute() { TocFile tf = new TocFile(); // The file might not exist, if the project has no TOC files and a TOC entry was dynamically generated if (File.Exists(this.InputPath.ItemSpec)) { using (TextReader r = new StreamReader(this.InputPath.ItemSpec, Encoding.UTF8, true)) { tf.Read(r); } } using (TextWriter w = new StreamWriter(this.OutputPath.ItemSpec, false, Encoding.UTF8)) { if (!IsFieldSet(tf, "X-AutoGenerated")) SetField(tf, "X-AutoGenerated", "true"); if (!IsFieldSet(tf, "X-GeneratorComment")) SetField(tf, "X-GeneratorComment", generatorComment); SetField(tf, "Interface", this.InterfaceVersion); SetField(tf, "Title", this.AddonTitle); SetField(tf, "Notes", this.AddonNotes); SetField(tf, "Dependencies", this.Dependencies); SetField(tf, "SavedVariables", this.SavedVariables); SetField(tf, "SavedVariablesPerCharacter", this.SavedVariablesPerCharacter); SetField(tf, "Author", this.Author); SetField(tf, "Version", this.AddonVersion); SetField(tf, "X-eMail", this.AuthorEmail); tf.Files.Clear(); if (this.Files != null) { foreach (ITaskItem item in this.Files) { tf.Files.Add(item.ItemSpec); } } tf.Write(w); } return true; }
private static bool IsFieldSet(TocFile file, string name) { return(file[name] != null); }