//----------------------------------------------------------------------------- // General //----------------------------------------------------------------------------- // Returns true if this parameter is valid as the given type. public bool IsValidType(CommandParamType checkType) { if (checkType == CommandParamType.Any) { return(true); } if (type == CommandParamType.Array || checkType == CommandParamType.Array) { return(type == checkType); } if (checkType == CommandParamType.String) { return(true); } if (checkType == CommandParamType.Integer) { int intValue; return(int.TryParse(stringValue, out intValue)); } if (checkType == CommandParamType.Float) { float floatValue; return(float.TryParse(stringValue, out floatValue)); } if (checkType == CommandParamType.Boolean) { bool boolValue; return(bool.TryParse(stringValue, out boolValue)); } return(false); }
public CommandParam(CommandParamType type) { this.name = ""; this.parent = null; this.children = null; this.nextParam = null; this.type = type; this.count = 0; this.value = null; this.charIndex = -1; this.lineIndex = -1; }
public CommandReferenceParam(CommandParamType type) { this.type = type; this.nextParam = null; this.parent = null; this.children = null; this.defaultValue = null; this.value = null; this.name = ""; if (type == CommandParamType.Array) value = (int) 0; }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public CommandParam(string str) { stringValue = str; parent = null; type = CommandParamType.String; count = 0; // TODO: parse int/float. float.TryParse(str, out floatValue); int.TryParse(str, out intValue); bool.TryParse(str, out boolValue); }
public CommandReferenceParam(CommandParamType type) { this.type = type; this.nextParam = null; this.parent = null; this.children = null; this.defaultValue = null; this.value = null; this.name = ""; if (type == CommandParamType.Array) { value = (int)0; } }
public CommandParam(CommandParam copy) { this.name = copy.name; this.type = copy.Type; this.parent = null; this.nextParam = null; this.value = copy.value; this.stringValue = copy.stringValue; this.charIndex = copy.charIndex; this.lineIndex = copy.lineIndex; // Copy array children. this.count = 0; if (type == CommandParamType.Array) { foreach (CommandParam copyChild in copy.GetChildren()) AddChild(new CommandParam(copyChild)); } }
public CommandParam(CommandReferenceParam referenceParam) : this() { this.name = referenceParam.Name; this.type = referenceParam.Type; // Copy array children. this.count = 0; if (type == CommandParamType.Array) { CommandReferenceParam copyChild = referenceParam.Children; while (copyChild != null) { AddChild(new CommandParam(copyChild)); copyChild = copyChild.NextParam; } } }
public CommandParam(CommandParam copy) { this.name = copy.name; this.type = copy.Type; this.parent = null; this.nextParam = null; this.value = copy.value; this.stringValue = copy.stringValue; this.charIndex = copy.charIndex; this.lineIndex = copy.lineIndex; // Copy array children. this.count = 0; if (type == CommandParamType.Array) { foreach (CommandParam copyChild in copy.GetChildren()) { AddChild(new CommandParam(copyChild)); } } }
//----------------------------------------------------------------------------- // General //----------------------------------------------------------------------------- // Returns true if this parameter is valid as the given type. public bool IsValidType(CommandParamType checkType) { if (checkType == CommandParamType.Any) return true; if (type == CommandParamType.Array || checkType == CommandParamType.Array) return (type == checkType); if (checkType == CommandParamType.String) return true; if (checkType == CommandParamType.Integer) { int intValue; return int.TryParse(stringValue, out intValue); } if (checkType == CommandParamType.Float) { float floatValue; return float.TryParse(stringValue, out floatValue); } if (checkType == CommandParamType.Boolean) { bool boolValue; return bool.TryParse(stringValue, out boolValue); } return false; }