本文整理汇总了C#中System.Management.Automation.PSVariable.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# PSVariable.GetType方法的具体用法?C# PSVariable.GetType怎么用?C# PSVariable.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.PSVariable
的用法示例。
在下文中一共展示了PSVariable.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToAutoVariables
private bool AddToAutoVariables(PSVariable psvariable, string scope)
{
if ((scope == VariableContainerDetails.GlobalScopeName) ||
(scope == VariableContainerDetails.ScriptScopeName))
{
// We don't A) have a good way of distinguishing built-in from user created variables
// and B) globalScopeVariables.Children.ContainsKey() doesn't work for built-in variables
// stored in a child variable container within the globals variable container.
return false;
}
var constantAllScope = ScopedItemOptions.AllScope | ScopedItemOptions.Constant;
var readonlyAllScope = ScopedItemOptions.AllScope | ScopedItemOptions.ReadOnly;
// Some local variables, if they exist, should be displayed by default
if (psvariable.GetType().Name == "LocalVariable")
{
if (psvariable.Name.Equals("_"))
{
return true;
}
else if (psvariable.Name.Equals("args", StringComparison.OrdinalIgnoreCase))
{
var array = psvariable.Value as Array;
return array != null ? array.Length > 0 : false;
}
return false;
}
else if (psvariable.GetType() != typeof(PSVariable))
{
return false;
}
if (((psvariable.Options | constantAllScope) == constantAllScope) ||
((psvariable.Options | readonlyAllScope) == readonlyAllScope))
{
string prefixedVariableName = VariableDetails.DollarPrefix + psvariable.Name;
if (this.globalScopeVariables.Children.ContainsKey(prefixedVariableName))
{
return false;
}
}
if ((psvariable.Value != null) && (psvariable.Value.GetType() == typeof(PSDebugContext)))
{
return false;
}
return true;
}