private FileRegexUpdater ConfigureFileRegexUpdater(FileRegexUpdater updater, ITaskItem step) { updater.Path = step.GetMetadata("Path"); string elementName = step.GetMetadata("ElementName"); string manualRegex = step.GetMetadata("Regex"); if (!string.IsNullOrEmpty(elementName)) { updater.Regex = CreateXmlUpdateRegex(elementName, nameof(elementName)); updater.VersionGroupName = nameof(elementName); } else if (!string.IsNullOrEmpty(manualRegex)) { updater.Regex = new Regex(manualRegex); updater.VersionGroupName = GetRequiredMetadata(step, "VersionGroupName"); } else { throw new ArgumentException( $"On '{step.ItemSpec}', did not find 'ElementName' or 'Regex' metadata."); } updater.SkipIfNoReplacementFound = string.Equals( step.GetMetadata(nameof(updater.SkipIfNoReplacementFound)), "true", StringComparison.OrdinalIgnoreCase); return(updater); }
private FileRegexUpdater ConfigureFileRegexUpdater(FileRegexUpdater updater, ITaskItem step) { updater.Path = step.GetMetadata("Path"); string elementName = step.GetMetadata("ElementName"); string manualRegex = step.GetMetadata("Regex"); if (!string.IsNullOrEmpty(elementName)) { updater.Regex = CreateXmlUpdateRegex(elementName, nameof(elementName)); updater.VersionGroupName = nameof(elementName); } else if (!string.IsNullOrEmpty(manualRegex)) { updater.Regex = new Regex(manualRegex); updater.VersionGroupName = GetRequiredMetadata(step, "VersionGroupName"); } else { throw new ArgumentException( $"On '{step.ItemSpec}', did not find 'ElementName' or 'Regex' metadata."); } return(updater); }