internal RuntimeDefinedParameter GetRuntimeDefinedParameter(bool isCmdlet) { TypeLiteral lastType = ParameterNode.GetLastType(this._parameter.TypeConstraint); Collection <Attribute> attributes = new Collection <Attribute>(); bool flag = false; foreach (AttributeNode attribute1 in this._attributes) { Attribute attribute2 = attribute1.GetAttribute(); if (attribute2 != null) { if (attribute2 is ParameterAttribute) { flag = true; } attributes.Add(attribute2); } } if (isCmdlet && !flag) { ParameterAttribute parameterAttribute = new ParameterAttribute(); attributes.Insert(0, (Attribute)parameterAttribute); } RuntimeDefinedParameter definedParameter = lastType != null ? new RuntimeDefinedParameter(this._parameter.VariableName, lastType, attributes) : new RuntimeDefinedParameter(this._parameter.VariableName, typeof(object), attributes); if (this._initializer != null) { definedParameter.Value = (object)this._initializer; } else if (definedParameter.ParameterType == typeof(string)) { definedParameter.Value = (object)""; } else if (definedParameter.ParameterType == typeof(bool)) { definedParameter.Value = (object)false; } else if (definedParameter.ParameterType == typeof(SwitchParameter)) { definedParameter.Value = (object)new SwitchParameter(false); } else if (LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(definedParameter.ParameterType))) { definedParameter.Value = (object)0; } return(definedParameter); }
internal bool IsSwitchParameter() { TypeLiteral lastType = ParameterNode.GetLastType(this._parameter.TypeConstraint); return(lastType != null && lastType.IsSwitchParameter); }