private object ParseParameter(string parameter, int i) { MemberInfo info = this.parametersByIndex[i]; Type type = this.GetParameterType(info); TinyParameterAttribute attribute = this.GetParameterAttribute(info); parameter = attribute.UnescapeParameter(parameter); if (type.IsAssignableFrom(typeof(string))) { return(parameter); } else { if (type.IsEnum) { return(Enum.Parse(type, parameter)); } else { return(Convert.ChangeType(parameter, type)); } } }
/// <summary> /// String representation of the command. /// </summary> /// <returns>String representation of the command.</returns> public override string ToString() { if (this.parametersByIndex == null) { this.PopulateParameters(); } StringBuilder paramBuilder = new StringBuilder(); for (int i = 0; i < this.parametersByIndex.Count; i++) { MemberInfo mi = this.parametersByIndex.Values[i]; TinyParameterAttribute attribute = (TinyParameterAttribute)mi.GetCustomAttributes(typeof(TinyParameterAttribute), false)[0]; paramBuilder.Append(" " + attribute.FormatParameter(this[i])); } return(this.CommandString + paramBuilder); }