protected override IEnumerable <object?> TransformMany(object inputData, EngineIntrinsics engineIntrinsics) { if (inputData is null) { yield return(inputData); yield break; } var inputValues = LanguagePrimitives.ConvertTo <object[]>(inputData); var values = ConstantDefinition.GetValues(DefiningType, IncludeInherited); foreach (var input in inputValues) { var value = values.Where(i => i.Name.Equals(input?.ToString(), StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (value != null) { yield return(value.Value); } else if (ThrowIfNotMatch) { throw new PSArgumentException($"The type [{DefiningType}] does not define a public constant value named '{input}'.", nameof(inputData)); } else { yield return(input); } } }
public IEnumerable <CompletionResult> CompleteArgument(string commandName, string parameterName, string wordToComplete, CommandAst commandAst, IDictionary fakeBoundParameters) { var values = ConstantDefinition.GetValues(_type, _includeInherited); foreach (var val in values) { yield return(CreateCompletionResult(val.Name)); } }