예제 #1
0
        public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
        {
            var expression = Expression.Constant("");
            var result     = new PrefixSearch <CustomEntity>(":=", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));

            return((bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke());
        }
예제 #2
0
        private void CreateList()
        {
            string pat      = @"^(\d*)\W*([^;]*)(;|$)\W*(\d*[,.]?\d*)\W*(\d*[,.]?\d*)";
            Regex  r        = new Regex(pat);
            int    maxLines = txtTariff.LineCount;

            for (int i = 0; i < maxLines; i++)
            {
                string line = txtTariff.GetLineText(i).TrimEnd(new Char[] { '\r', '\n' });
                if (!string.IsNullOrWhiteSpace(line))
                {
                    Match m = r.Match(line);
                    if (!(string.IsNullOrWhiteSpace(m.Groups[2] + "")))
                    {
                        string prefix      = m.Groups[1] + "";
                        string description = m.Groups[2] + "";
                        if (string.IsNullOrWhiteSpace(prefix))
                        {
                            string[] c = PrefixSearch.SearchPrefix(description);
                            if (c != null)
                            {
                                prefix      = c[0];
                                description = c[1];
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(prefix))
                        {
                            float pMin, pCall;
                            if (string.IsNullOrWhiteSpace(m.Groups[4] + "") && string.IsNullOrWhiteSpace(m.Groups[5] + ""))
                            {
                                float.TryParse(txtDefPriceMin.Text, out pMin);
                                float.TryParse(txtDefPriceCall.Text, out pCall);
                            }
                            else
                            {
                                float.TryParse(m.Groups[4] + "", out pMin);
                                float.TryParse(m.Groups[5] + "", out pCall);
                            }
                            tariffList.Add(new Country(description, prefix)
                            {
                                PriceMin = pMin, PriceCall = pCall
                            });
                        }
                    }
                }
            }
        }
예제 #3
0
        private void btn_Check_Click(object sender, RoutedEventArgs e)
        {
            string pat      = @"^(\d*)\W*([^;]*)(;|$)\W*(\d*[,.]?\d*)\W*(\d*[,.]?\d*)";
            Regex  r        = new Regex(pat);
            int    maxLines = txtTariff.LineCount;

            for (int i = 0; i < maxLines; i++)
            {
                string line = txtTariff.GetLineText(i).TrimEnd(new Char[] { '\r', '\n' });
                if (!string.IsNullOrWhiteSpace(line))
                {
                    Match  m           = r.Match(line);
                    string prefix      = m.Groups[1] + "";
                    string description = m.Groups[2] + "";
                    if (string.IsNullOrWhiteSpace(prefix))
                    {
                        int      position = txtTariff.GetCharacterIndexFromLineIndex(i);
                        string[] c        = PrefixSearch.SearchPrefix(description);
                        if (c != null)
                        {
                            prefix      = c[0];
                            description = c[1];
                            txtTariff.SelectionStart  = position;
                            txtTariff.SelectionLength = (m.Groups[2] + "").Length;
                            txtTariff.SelectedText    = prefix + " " + description;
                        }
                        else
                        {
                            txtTariff.Focus();
                            txtTariff.SelectionStart  = position;
                            txtTariff.SelectionLength = line.Length;
                            return;
                        }
                    }
                }
            }
        }
예제 #4
0
 public void SetUp()
 {
     testee = new PrefixSearch <CustomEntity>(":=");
 }
예제 #5
0
 public bool CompareShouldBeAffectedIgnoreCase(string left, string right, bool ignoreCase)
 {
     var expression = Expression.Constant("");
     var result = new PrefixSearch<CustomEntity>(":=", ignoreCase).Compare(expression, OperandBuilder.BuildUp(left), OperandBuilder.BuildUp(right));
     return (bool)Expression.Lambda(result.Expression).Compile().DynamicInvoke();
 }
예제 #6
0
 public void SetUp()
 {
     testee = new PrefixSearch<CustomEntity>(":=");
 }