示例#1
0
        private void MatchRegex(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                Match result = RE.Match(TextToMatch);
                lbRegex.Text       = RE.ToString();
                lbMatchedText.Text = TextToMatch;

                if (result.Success)
                {
                    // Reset settings
                    lbStatus.ForeColor       = System.Drawing.Color.DarkGreen;
                    lbStatus.Text            = "Matched!";
                    label2.Visible           = true;
                    lstMatchedGroups.Visible = true;
                    lstMatchedGroups.Items.Clear();

                    lbMatchedText.Text = result.Value;

                    for (int i = 0; i < result.Groups.Count; i++)
                    {
                        lstMatchedGroups.Items.Add("Grupo " + i + ": " + result.Groups[i]);
                    }
                }
                else
                {
                    lbStatus.ForeColor       = System.Drawing.Color.Red;
                    lbStatus.Text            = "Didn't match";
                    label2.Visible           = false;
                    lstMatchedGroups.Visible = false;
                }
            }
        }
示例#2
0
        public string GenerateClassName(string interfaceCode)
        {
            var match           = RE.Match(interfaceCode);
            var name            = match.Groups[1].Value;
            var firstTwoLetters = name.Substring(0, 2);
            var newName         = firstTwoLetters.Length == 2 && firstTwoLetters[0] == 'I' && char.IsUpper(firstTwoLetters[1])
                ? name.Substring(1)
                : name;

            return(newName + "Decorator");
        }
示例#3
0
        private void RefreshListMerged(TProfInstance Parent)
        {
            TProfFunc Func;
            string    LastInst;
            string    Q;
            bool      Delete;

            System.Text.RegularExpressions.Regex RE = null;
            double SumSelf;
            double SumSelfPercent;
            int    SumCalls;

            //lFind.Caption := '';  //TODO: set the text/caoption
            LastInst = string.Empty;
            if (lvMerged.SelectedItems.Count > 0)
            {
                LastInst = lvMerged.SelectedItems[0].Name;
            }

            FListMerged.Clear();
            SumSelf        = 0;
            SumSelfPercent = 0;
            SumCalls       = 0;
            Parent.GetMerged(ref FListMerged);
            // filter

            if (cbRE.Checked)
            {
                Q = cbFind.Text;
                if (!String.IsNullOrEmpty(Q))
                {
                    try
                    {
                        RE = new System.Text.RegularExpressions.Regex(Q, RegexOptions.IgnoreCase);
                    }
                    catch (Exception)
                    {
                        Q = string.Empty;
                        //TODO: show proper error in lFind
                        //lFind.Caption := 'Pattern invalid';
                        //lFind.Visible := True;
                    }
                }
            }
            else
            {
                Q = cbFind.Text.Trim().ToLower();
            }
            for (int i = FListMerged.Count - 1; i > -1; i--)
            {
                Func = FListMerged[i];
                // filtering
                Delete = false;
                // filter for hide funcs
                if (config.HideLibFuncs && (Func.Kind == TFuncKind.fkLibFunc))
                {
                    Delete = true;
                }
                // hide fast funcs
                else if (config.HideFastFuncs && (Func.TotCumTime < config.FastThreshold))
                {
                    Delete = true;
                }
                // find
                else if (Q != "")
                {
                    if (cbRE.Checked)
                    {
                        Match m = RE.Match(Func.Name);
                        if (!m.Success)
                        {
                            Delete = true;
                        }
                    }
                    else
                    {
                        if (Func.Name.ToLower().IndexOf(Q) <= 0)
                        {
                            Delete = true;
                        }
                    }
                }
                if (Delete)
                {
                    FListMerged.RemoveAt(i);
                }
                else
                {
                    // calculate sum
                    SumSelf        = SumSelf + Func.TotSelfTime;
                    SumSelfPercent = SumSelfPercent + Func.TotSelfPercent;
                    SumCalls       = SumCalls + Func.InstanceCount;
                }
            }

            // ok, continue
            //FListMerged.Sort(MergedSort); //TODO: sort
            //lvMerged.Items.Count := FListMerged.Count;
            // select last function if available
            //SelectListItem(lvMerged, 0);
            SelectMergedFunc(LastInst);
            lvMergedInvalidate();
            lMerged.Text = " Sum of total self time: " + FormatMs(SumSelf) + " (" + FormatPercent(SumSelfPercent) + ")"
                           + "   Sum of calls: " + string.Format("{0:0}", (SumCalls * 1.0));
        }
示例#4
0
        public string Generate(string code)
        {
            var match = RE.Match(code);

            return(match.Groups[1].Value + ".cs");
        }