File size: 2,446 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
namespace Microsoft.PowerShell.Cmdletization
{
/// <summary>
/// Describes how to handle the method parameter.
/// </summary>
[Flags]
public enum MethodParameterBindings
{
/// <summary>
/// Bind value of a method parameter based on arguments of a cmdlet parameter.
/// </summary>
In = 1,
/// <summary>
/// Method invocation is expected to set the value of the method parameter. Cmdlet should emit the value of method parameter to the downstream pipe.
/// </summary>
Out = 2,
/// <summary>
/// Method invocation is expected to set the value of the method parameter. Cmdlet should emit a non-terminating error when the value evaluates to $true.
/// </summary>
Error = 4,
}
/// <summary>
/// Parameter of a method in an object model wrapped by <see cref="CmdletAdapter<TObjectInstance>"/>
/// </summary>
public sealed class MethodParameter
{
/// <summary>
/// Name of the method parameter.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Type of the parameter (as seen in the PowerShell layer on the client)
/// </summary>
public Type ParameterType { get; set; }
/// <summary>
/// Contents of the ETS type attribute in the CDXML file (or <see langword="null"/> if that attribute was not specified).
/// The expectation is that the CmdletAdapter will stamp this value onto PSTypeNames of emitted objects.
/// </summary>
public string ParameterTypeName { get; set; }
/// <summary>
/// Bindings of the method parameter (in/out/error)
/// </summary>
public MethodParameterBindings Bindings { get; set; }
/// <summary>
/// Value of the argument of the method parameter.
/// </summary>
public object Value { get; set; }
/// <summary>
/// Whether the value is 1) an explicit default (*) or 2) has been bound from cmdlet parameter
/// (*) explicit default = whatever was in DefaultValue attribute in Cmdletization XML.
/// </summary>
public bool IsValuePresent { get; set; }
// TODO/FIXME: this should be renamed to ValueExplicitlySpecified or something like this
}
}
|