Ejemplo n.º 1
0
        KeyFrom[] BuildKeyFromArray(string strText)
        {
            if (String.IsNullOrEmpty(strText) == true)
            {
                return(null);
            }

            List <KeyFrom> results = new List <KeyFrom>();

            string[] lines = strText.Split(new char[] { DpResultSetManager.SPLIT });
            for (int i = 0; i < lines.Length; i++)
            {
                string strLine = lines[i];
                if (String.IsNullOrEmpty(strLine) == true)
                {
                    continue;
                }

                string strKey  = "";
                string strFrom = "";

                char chLogic = (char)0;  // none
                if (strLine[0] == DpResultSetManager.OR ||
                    strLine[0] == DpResultSetManager.AND)
                {
                    chLogic = strLine[0];
                    strLine = strLine.Substring(1);
                }

                int nRet = strLine.IndexOf(DpResultSetManager.FROM_LEAD);
                if (nRet == -1)
                {
                    strKey = strLine;
                }
                else
                {
                    strKey  = strLine.Substring(0, nRet);
                    strFrom = strLine.Substring(nRet + 1);
                }

                KeyFrom keyfrom = new KeyFrom();
                if (chLogic == DpResultSetManager.OR)
                {
                    keyfrom.Logic = "OR";
                }
                else if (chLogic == DpResultSetManager.AND)
                {
                    keyfrom.Logic = "AND";
                }
                keyfrom.Key  = strKey;
                keyfrom.From = strFrom;

                results.Add(keyfrom);
            }

            KeyFrom[] keyfroms = new KeyFrom[results.Count];
            results.CopyTo(keyfroms);

            return(keyfroms);
        }
Ejemplo n.º 2
0
        static int GetLength(KeyFrom[] list)
        {
            if (list == null || list.Length == 0)
                return 0;
            int nLength = 0;
            foreach (KeyFrom item in list)
            {
                if (item == null)
                    continue;
                if (item.Key != null)
                    nLength += item.Key.Length;
                if (item.From != null)
                    nLength += item.From.Length;
                if (item.Logic != null)
                    nLength += item.Logic.Length;
            }

            return nLength;
        }
Ejemplo n.º 3
0
        KeyFrom[] BuildKeyFromArray(string strText)
        {
            if (String.IsNullOrEmpty(strText) == true)
                return null;

            List<KeyFrom> results = new List<KeyFrom>();
            string[] lines = strText.Split(new char[] { DpResultSetManager.SPLIT });
            for (int i = 0; i < lines.Length; i++)
            {
                string strLine = lines[i];
                if (String.IsNullOrEmpty(strLine) == true)
                    continue;

                string strKey = "";
                string strFrom = "";

                char chLogic = (char)0;  // none
                if (strLine[0] == DpResultSetManager.OR
                    || strLine[0] == DpResultSetManager.AND)
                {
                    chLogic = strLine[0];
                    strLine = strLine.Substring(1);
                }

                int nRet = strLine.IndexOf(DpResultSetManager.FROM_LEAD);
                if (nRet == -1)
                    strKey = strLine;
                else
                {
                    strKey = strLine.Substring(0, nRet);
                    strFrom = strLine.Substring(nRet + 1);
                }

                KeyFrom keyfrom = new KeyFrom();
                if (chLogic == DpResultSetManager.OR)
                    keyfrom.Logic = "OR";
                else if (chLogic == DpResultSetManager.AND)
                    keyfrom.Logic = "AND";
                keyfrom.Key = strKey;
                keyfrom.From = strFrom;

                results.Add(keyfrom);
            }

            KeyFrom[] keyfroms = new KeyFrom[results.Count];
            results.CopyTo(keyfroms);

            return keyfroms;
        }