Esempio n. 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);
        }
Esempio n. 2
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;
 }
Esempio n. 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;
 }
Esempio n. 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);
        }
Esempio n. 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;
     }
 }
Esempio n. 7
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));
            }
        }
Esempio n. 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;
                }
            }
        }
Esempio n. 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));
                }
            }
        }
Esempio n. 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;
                }
            }
        }
Esempio n. 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;
 }