private PipelineContext(ILogger logger, PSRuleOption option, HostContext hostContext, TargetBinder binder, BaselineContext baseline, IDictionary <string, ResourceRef> unresolved) { _ObjectNumber = -1; _Logger = logger; _RuleTimer = new Stopwatch(); Option = option; HostContext = hostContext; _LanguageMode = option.Execution.LanguageMode ?? ExecutionOption.Default.LanguageMode.Value; _InconclusiveWarning = option.Execution.InconclusiveWarning ?? ExecutionOption.Default.InconclusiveWarning.Value; _NotProcessedWarning = option.Execution.NotProcessedWarning ?? ExecutionOption.Default.NotProcessedWarning.Value; _FailStream = option.Logging.RuleFail ?? LoggingOption.Default.RuleFail.Value; _PassStream = option.Logging.RulePass ?? LoggingOption.Default.RulePass.Value; _NameTokenCache = new Dictionary <string, NameToken>(); DataCache = new Dictionary <string, Hashtable>(); ExpressionCache = new Dictionary <string, object>(); _Reason = new List <string>(); _Binder = binder; Baseline = baseline; _Unresolved = unresolved; Culture = option.Output.Culture; }
/// <summary> /// Bind target object based on the supplied baseline. /// </summary> public void Bind(BaselineContext baseline, PSObject targetObject) { var binding = baseline.GetTargetBinding(); TargetName = _BindTargetName(binding.TargetName, !binding.IgnoreCase, targetObject); TargetType = _BindTargetType(binding.TargetType, !binding.IgnoreCase, targetObject); ShouldFilter = !(_TypeFilter == null || _TypeFilter.Contains(TargetType)); BindField(binding.Field, !binding.IgnoreCase, targetObject); }
private BaselineContext GetBaselineContext() { var result = new BaselineContext(); var scope = new BaselineContext.BaselineContextScope(type: BaselineContext.ScopeType.Workspace, moduleName: null, option: Option); result.Add(scope); scope = new BaselineContext.BaselineContextScope(type: BaselineContext.ScopeType.Parameter, include: _Include, tag: _Tag); result.Add(scope); return(result); }
/// <summary> /// Bind target object based on the supplied baseline. /// </summary> public void Bind(BaselineContext baseline, PSObject targetObject) { var binding = baseline.GetTargetBinding(); TargetName = _BindTargetName(binding.TargetName, !binding.IgnoreCase, targetObject); TargetType = _BindTargetType(binding.TargetType, !binding.IgnoreCase, targetObject); ShouldFilter = !(_TypeFilter == null || _TypeFilter.Contains(TargetType)); // Use qualified name if (binding.UseQualifiedName) { TargetName = string.Concat(TargetType, binding.NameSeparator, TargetName); } // Bind custom fields BindField(binding.Field, !binding.IgnoreCase, targetObject); }
private PipelineContext(PSRuleOption option, HostContext hostContext, TargetBinder binder, BaselineContext baseline, IDictionary <string, ResourceRef> unresolved) { Option = option; HostContext = hostContext; _LanguageMode = option.Execution.LanguageMode ?? ExecutionOption.Default.LanguageMode.Value; _NameTokenCache = new Dictionary <string, NameToken>(); LocalizedDataCache = new Dictionary <string, Hashtable>(); ExpressionCache = new Dictionary <string, object>(); ContentCache = new Dictionary <string, PSObject[]>(); Binder = binder; Baseline = baseline; _Unresolved = unresolved; Culture = option.Output.Culture; }
public static PipelineContext New(ILogger logger, PSRuleOption option, HostContext hostContext, TargetBinder binder, BaselineContext baseline, IDictionary <string, ResourceRef> unresolved) { var context = new PipelineContext(logger, option, hostContext, binder, baseline, unresolved); CurrentThread = context; return(context); }