本文整理汇总了C#中System.Management.Automation.PSVariable.AddParameterAttributesNoChecks方法的典型用法代码示例。如果您正苦于以下问题:C# PSVariable.AddParameterAttributesNoChecks方法的具体用法?C# PSVariable.AddParameterAttributesNoChecks怎么用?C# PSVariable.AddParameterAttributesNoChecks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.PSVariable
的用法示例。
在下文中一共展示了PSVariable.AddParameterAttributesNoChecks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindParameter
internal override void BindParameter(string name, object value)
{
if ((value == AutomationNull.Value) || (value == UnboundParameter.Value))
{
value = null;
}
VariablePath variablePath = new VariablePath(name, VariablePathFlags.Variable);
if (((this.LocalScope == null) || !variablePath.IsAnyLocal()) || !this.LocalScope.TrySetLocalParameterValue(variablePath.UnqualifiedPath, this.CopyMutableValues(value)))
{
RuntimeDefinedParameter parameter;
PSVariable newValue = new PSVariable(variablePath.UnqualifiedPath, value, variablePath.IsPrivate ? ScopedItemOptions.Private : ScopedItemOptions.None);
base.Context.EngineSessionState.SetVariable(variablePath, newValue, false, CommandOrigin.Internal);
if (this.Script.RuntimeDefinedParameters.TryGetValue(name, out parameter))
{
newValue.AddParameterAttributesNoChecks(parameter.Attributes);
}
}
}
示例2: BindParameter
/// <summary>
/// Binds the parameters to local variables in the function scope
/// </summary>
/// <param name="name">
/// The name of the parameter to bind the value to.
/// </param>
/// <param name="value">
/// The value to bind to the parameter. It should be assumed by
/// derived classes that the proper type coercion has already taken
/// place and that any prerequisite metadata has been satisfied.
/// </param>
/// <param name="parameterMetadata"></param>
internal override void BindParameter(string name, object value, CompiledCommandParameter parameterMetadata)
{
if (value == AutomationNull.Value || value == UnboundParameter.Value)
{
value = null;
}
Diagnostics.Assert(name != null, "The caller should verify that name is not null");
var varPath = new VariablePath(name, VariablePathFlags.Variable);
// If the parameter was allocated in the LocalsTuple, we can avoid creating a PSVariable,
if (LocalScope != null
&& varPath.IsAnyLocal()
&& LocalScope.TrySetLocalParameterValue(varPath.UnqualifiedPath, CopyMutableValues(value)))
{
return;
}
// Otherwise we'll fall through and enter a new PSVariable in the current scope. This
// is what normally happens when dotting (though the above may succeed if a parameter name
// was an automatic variable like $PSBoundParameters.
// First we need to make a variable instance and apply
// any attributes from the script.
PSVariable variable = new PSVariable(varPath.UnqualifiedPath, value,
varPath.IsPrivate ? ScopedItemOptions.Private : ScopedItemOptions.None);
Context.EngineSessionState.SetVariable(varPath, variable, false, CommandOrigin.Internal);
RuntimeDefinedParameter runtimeDefinedParameter;
if (Script.RuntimeDefinedParameters.TryGetValue(name, out runtimeDefinedParameter))
{
// The attributes have already been checked and conversions run, so it is wrong
// to do so again.
variable.AddParameterAttributesNoChecks(runtimeDefinedParameter.Attributes);
}
} // BindParameter