/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/QueryJobBase.cs
80 строк
3 KB
xtqqczze
Fix IDE0044: MakeFieldReadonly part 3 (#13886)
29 окт 2020, 14:03
Не верифицирован
29 окт 2020, 14:03
bcca5f4
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Management.Automation; using Microsoft.Management.Infrastructure; using Dbg = System.Management.Automation.Diagnostics; namespace Microsoft.PowerShell.Cmdletization.Cim { /// <summary> /// Base job for queries. /// </summary> internal abstract class QueryJobBase : CimChildJobBase<CimInstance> { private readonly CimQuery _cimQuery; internal QueryJobBase(CimJobContext jobContext, CimQuery cimQuery) : base(jobContext) { Dbg.Assert(cimQuery != null, "Caller should verify cimQuery != null"); _cimQuery = cimQuery; } public override void OnNext(CimInstance item) { this.ExceptionSafeWrapper( delegate { Dbg.Assert(item != null, "When OnNext is called from our IObservable, item parameter should always be != null"); if (item == null) { return; } if (!_cimQuery.IsMatchingResult(item)) { return; } this.WriteObject(item); }); } public override void OnCompleted() { this.ExceptionSafeWrapper( delegate { foreach (ClientSideQuery.NotFoundError notFoundError in _cimQuery.GenerateNotFoundErrors()) { string errorId = "CmdletizationQuery_NotFound"; if (!string.IsNullOrEmpty(notFoundError.PropertyName)) { errorId = errorId + "_" + notFoundError.PropertyName; } CimJobException cimJobException = CimJobException.CreateWithFullControl( this.JobContext, notFoundError.ErrorMessageGenerator(this.Description, this.JobContext.ClassName), errorId, ErrorCategory.ObjectNotFound); if (!string.IsNullOrEmpty(notFoundError.PropertyName)) { cimJobException.ErrorRecord.SetTargetObject(notFoundError.PropertyValue); } this.WriteError(cimJobException.ErrorRecord); } }); base.OnCompleted(); } internal override CimCustomOptionsDictionary CalculateJobSpecificCustomOptions() { return CimCustomOptionsDictionary.Create(_cimQuery.queryOptions); } } }