Exemple #1
0
		protected bool AddArrayParameter(string parameter, IEnumerable<object> value)
		{
			if (!this.parameters.ContainsKey(parameter))
			{
				TypeWrapper typeWrapper = new TypeWrapper(this.cmdletInfo.GetParameterType(parameter));
				if (TypeSystem.IsArrayType(typeWrapper.Value))
				{
					this.commonParameterFlag = this.GetCommonParameterSets(parameter);
					this.parameters.Add(parameter, value.ToArray<object>());
					return true;
				}
				else
				{
					TraceHelper.Current.DebugMessage(string.Format(Resources.ParameterNotDefinedAsArray, parameter, this.cmdletInfo.CmdletName));
					return false;
				}
			}
			else
			{
				TraceHelper.Current.DebugMessage(string.Format(Resources.ParameterAlreadyAddedToCommand, parameter, this.cmdletInfo.CmdletName));
				return false;
			}
		}
Exemple #2
0
		public static object ConvertEnumerableToCollection(object value, string convertToTypeName)
		{
			if (value != null && TypeSystem.ContainsEnumerableInterface(value.GetType()))
			{
				TypeWrapper typeWrapper = new TypeWrapper(convertToTypeName);
				value = TypeSystem.ConvertEnumerableToCollection(value, typeWrapper.Value);
			}
			return value;
		}