Beispiel #1
0
        public string GetValue(string fullkey, string parameterstyle)
        {
            // return the appropriate value
            string output     = "";
            lookup checkvalue = this._values.FindAll(x => x.fullkey.Equals(fullkey) && x.parameterstyle.Equals(parameterstyle)).FirstOrDefault();

            if (checkvalue != null)
            {
                output = checkvalue.value;
            }
            return(output);
        }
Beispiel #2
0
        public string GetValue(string fullkey)
        {
            // return the FIRST appropriate value REGARDLESS of type
            string output     = "";
            lookup checkvalue = this._values.FindAll(x => x.fullkey.Equals(fullkey)).FirstOrDefault();

            if (checkvalue != null)
            {
                output = checkvalue.value;
            }
            return(output);
        }
Beispiel #3
0
        public bool AnalyseParts(List <lookup> rawparts)
        {
            // step through each part and check it against the parameter rules
            // get all syn
            string currentparent = "";
            string currentstyle  = "";

            foreach (lookup thispart in rawparts)
            {
                // check this in the synonyms
                command match = this._commands.FindAll(x => x.synonym.Equals(thispart.value) && x.parent.Equals(currentparent)).FirstOrDefault();
                if (match == null)
                {
                    // is a "data" item: set this in the type property of the parent
                    thispart.parameterstyle = "Data";
                    thispart.fullkey        = currentparent;

                    // now put this into the "value" field of the parent
                    if (currentstyle == "Option" || currentstyle == "Command")
                    {
                        // find the parent and insert this value into the
                        if (thispart.value != "")
                        {
                            lookup valuematch = this._values.FindAll(x => x.fullkey.Equals(thispart.fullkey)).FirstOrDefault();
                            if (valuematch.value == "")
                            {
                                // put this in
                                valuematch.value = thispart.value;
                            }
                            else if (this.takefirstvalueonly == false)
                            {
                                valuematch.value = valuematch.value + ' ' + thispart.value;
                            }
                        }
                    }
                }
                else
                {
                    // this is a match: find the key and retrieve this from
                    command keymatch;
                    if (match.issynonym == true)
                    {
                        keymatch = this._commands.FindAll(x => x.key.Equals(match.key) && x.parent.Equals(currentparent)).FirstOrDefault();
                    }
                    else
                    {
                        keymatch = match;
                    }
                    if (keymatch != null)
                    {
                        // check the type: if a switch, we set it to true and do nothing else
                        if (keymatch.isswitch == true)
                        {
                            thispart.parameterstyle = "Switch";
                            thispart.fullkey        = (currentparent + ' ' + keymatch.key).Trim();
                            thispart.value          = "true";
                        }
                        else if (keymatch.isoption == true)
                        {
                            // the NEXT data item is the value: note that only the first of these is added
                            currentstyle  = "Option";
                            currentparent = (currentparent + ' ' + keymatch.key).Trim();

                            thispart.parameterstyle = "Option";
                            thispart.fullkey        = currentparent;
                            thispart.value          = "";
                        }
                        else if (keymatch.iscommand == true)
                        {
                            // the NEXT data item is the value: note that only the first of these is added
                            currentstyle  = "Command";
                            currentparent = (currentparent + ' ' + keymatch.key).Trim();

                            thispart.parameterstyle = "Command";
                            thispart.fullkey        = currentparent;
                            thispart.value          = "";
                        }
                    }
                }
            }

            return(true);
        }