Example #1
0
        private bool TryMatchParams(cmdInfo cmdInfo, cmdRequest cmdRequest, out Dictionary <string, string> keyParam)
        {
            var keyType   = cmdInfo.paramsKeyType;
            var reqParams = cmdRequest.cmdCommandParams;

            keyParam = new Dictionary <string, string>();

            if (reqParams.Length > keyType.Count)
            {
                return(false);
            }

            bool allTypesMatched = false;

            for (int i = 0; i < keyType.Count; i++)
            {
                if (allTypesMatched)
                {
                    break;
                }

                Type typeNeeded = keyType.ElementAt(i).Value;
                for (int j = 0; j < reqParams.Length; j++)
                {
                    try
                    {
                        var check = Convert.ChangeType(reqParams[j], typeNeeded);
                        keyParam.Add(keyType.ElementAt(i).Key, reqParams[j]);

                        if (keyParam.Count == reqParams.Length)
                        {
                            allTypesMatched = true;
                            break;
                        }
                    }
                    catch
                    { continue; }
                }
            }

            if (reqParams.Length > keyParam.Count)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #2
0
 public cmdResponse(cmdInfo cmdInfo, Dictionary <string, string> cmdParams)
 {
     this.action    = cmdInfo.action;
     this.cmdParams = cmdParams;
 }
Example #3
0
 public cmdResponse(cmdInfo cmdInfo) : this(cmdInfo, null)
 {
 }