コード例 #1
0
        /// <summary>
        /// Method to filter the values.
        /// </summary>
        /// <param name="unfilteredValues">The list of all values.</param>
        /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns>
        private List <Tuple <string, object, MISD.Core.DataType> > FilterValues(List <Tuple <string, object, MISD.Core.DataType> > unfilteredValues)
        {
            // Get old or default filter from plugin assembly
            if (this.Filter == null)
            {
                foreach (IndicatorSettings indicatorSetting in this.Plugin.GetIndicatorSettings())
                {
                    if (indicatorSetting.IndicatorName == this.Indicator)
                    {
                        this.Filter = indicatorSetting.FilterStatement;
                    }
                }
            }

            // Get filter expression
            this.Filter = ServerConnection.Instance.GetFilter(this.Plugin.GetName(), this.Indicator, this.Filter);

            // Filter values
            if (this.Filter == null || this.Filter.Trim() == "" || this.Filter.Trim() == ".")
            {
                // Here is no filtering required.
                return(unfilteredValues);
            }
            else
            {
                List <Tuple <string, object, MISD.Core.DataType> > filteredValues = new List <Tuple <string, object, MISD.Core.DataType> >();
                foreach (Tuple <string, object, MISD.Core.DataType> current in unfilteredValues)
                {
                    if (RegExUtility.Match(current.Item1, this.Filter))
                    {
                        filteredValues.Add(current);
                    }
                }
                return(filteredValues);
            }
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("++++++++++++++++++++++++++++++++");
                Console.WriteLine("+++ RegExUtilTestApplication +++");
                Console.WriteLine("++++++++++++++++++++++++++++++++");
                Console.WriteLine();
                Console.WriteLine("(1) >");
                Console.WriteLine("(2) <");
                Console.WriteLine("(3) =");
                Console.WriteLine("(4) contain");
                Console.WriteLine("(5) not_contain");
                Console.WriteLine();
                Console.WriteLine();

                Console.WriteLine("Choose one Operation: ");
                var key = Console.ReadKey();

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Enter value: ");
                var value = Console.ReadLine();

                string result = "";
                switch (((ConsoleKeyInfo)key).KeyChar)
                {
                case '1':
                    result = RegExUtility.GenerateRegEx(value, Operation.Major);
                    break;

                case '2':
                    result = RegExUtility.GenerateRegEx(value, Operation.Less);
                    break;

                case '3':
                    result = RegExUtility.GenerateRegEx(value, Operation.Equal);
                    break;

                case '4':
                    result = RegExUtility.GenerateRegEx(value, Operation.Contain);
                    break;

                case '5':
                    result = RegExUtility.GenerateRegEx(value, Operation.NotContain);
                    break;

                default:
                    break;
                }

                if (result != "")
                {
                    Console.WriteLine();
                    Console.WriteLine("Generated RegEx: ");
                    Console.WriteLine(result);

                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("++++++++++++++++++++++++++++++++");
                    Console.WriteLine("+++      Test the RegEx      +++");
                    Console.WriteLine("++++++++++++++++++++++++++++++++");

                    while (true)
                    {
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("Enter value: ");
                        var  testValue = Console.ReadLine();
                        bool matched   = Regex.Match(testValue, result).Success;

                        Console.WriteLine("Matched = " + matched);
                    }
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Operation not implemented...");
                    Console.ReadKey();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(">>> Program unexcepted closed");
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }
コード例 #3
0
        private void RegExMetricCriticalGenAdd_Click(object sender, RoutedEventArgs e)
        {
            if (MonitoringIndicatorList.SelectedItem != null)
            {
                RegExUtil.Operation op = RegExOperationConvertBack(this.RegExGenMetricCriticalOp.SelectedItem as string);
                string part            = RegExUtility.GenerateRegEx(RegExGeneratorMetricCritical.Text, op);
                string oldRegEx        = (MonitoringIndicatorList.SelectedItem as Indicator).StatementCritical;

                var mergeList = new List <string>();
                mergeList.Add(oldRegEx);
                mergeList.Add(part);

                (MonitoringIndicatorList.SelectedItem as Indicator).StatementCritical = RegExUtility.MergeRegEx(mergeList);
                RegExGeneratorMetricCritical.Text = "";
            }
        }