private PSRuleOption(string sourcePath, PSRuleOption option) { SourcePath = sourcePath; // Set from existing option instance Configuration = new ConfigurationOption(option?.Configuration); Output = new OutputOption(option?.Output); }
private static PSRuleOption Combine(PSRuleOption o1, PSRuleOption o2) { var result = new PSRuleOption(o1?.SourcePath ?? o2?.SourcePath, o1); result.Configuration = ConfigurationOption.Combine(result.Configuration, o2?.Configuration); result.Output = OutputOption.Combine(result.Output, o2?.Output); return(result); }
/// <summary> /// Load a YAML formatted PSRuleOption object from disk. /// </summary> /// <param name="path">A file or directory to read options from.</param> /// <returns>An options object.</returns> /// <remarks> /// This method is called from PowerShell. /// </remarks> public static PSRuleOption FromFileOrDefault(string path) { // Get a rooted file path instead of directory or relative path var filePath = GetFilePath(path); // Return empty options if file does not exist var result = !File.Exists(filePath) ? new PSRuleOption() : FromYaml(path: filePath, yaml: File.ReadAllText(filePath)); return(PSRuleOption.Combine(result, PSRuleOption.Default)); }