Example #1
0
        //-----------------------------------------------------------------------------
        // 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;
 }
Example #3
0
 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;
 }
Example #5
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);
        }
Example #6
0
 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));
            }
        }
Example #8
0
        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;
                }
            }
        }
Example #9
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));
                }
            }
        }
Example #10
0
        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;
                }
            }
        }
Example #11
0
 //-----------------------------------------------------------------------------
 // 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;
 }