コード例 #1
0
ファイル: Form1.cs プロジェクト: rushikkk/LVL1DomainHelper
 private void Form1_Load(object sender, EventArgs e)
 {
     domainName.Text = "2kakadu.by";
     hosterby.Add("178.172.136.0", "255.255.248.0");
     hosterby.Add("178.172.160.0", "255.255.252.0");
     hosterby.Add("178.172.201.0", "255.255.255.0");
     hosterby.Add("178.172.244.0", "255.255.255.0");
     hosterby.Add("178.172.250.0", "255.255.255.0");
     hosterby.Add("195.137.160.0", "255.255.255.0");
     hosterby.Add("93.125.99.0", "255.255.255.0");
 }
コード例 #2
0
 /// <summary>
 /// Add a route.
 /// </summary>
 /// <param name="method">The HTTP method.</param>
 /// <param name="path">URL path, i.e. /path/to/resource.</param>
 /// <param name="handler">Method to invoke.</param>
 public void Add(HttpMethod method, Regex path, Func <HttpRequest, HttpResponse> handler)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     if (handler == null)
     {
         throw new ArgumentNullException(nameof(handler));
     }
     _Matcher.Add(
         new Regex(BuildConsolidatedRegex(method, path)),
         handler);
 }
コード例 #3
0
        /// <summary>
        /// Add a route.
        /// </summary>
        /// <param name="method">The HTTP method.</param>
        /// <param name="path">URL path, i.e. /path/to/resource.</param>
        /// <param name="handler">Method to invoke.</param>
        /// <param name="guid">Globally-unique identifier.</param>
        /// <param name="metadata">User-supplied metadata.</param>
        public void Add(HttpMethod method, Regex path, Func<HttpContext, Task> handler, string guid = null, object metadata = null)
        {
            if (path == null) throw new ArgumentNullException(nameof(path));
            if (handler == null) throw new ArgumentNullException(nameof(handler));

            lock (_Lock)
            {
                DynamicRoute dr = new DynamicRoute(method, path, handler);

                _Matcher.Add(
                    new Regex(BuildConsolidatedRegex(method, path)),
                    dr);

                _Routes.Add(new DynamicRoute(method, path, handler, guid, metadata), handler);
            }
        }
コード例 #4
0
 public void Add(string verb, Regex path, Func <HttpRequest, HttpResponse> handler)
 {
     if (String.IsNullOrEmpty(verb))
     {
         throw new ArgumentNullException(nameof(verb));
     }
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     if (handler == null)
     {
         throw new ArgumentNullException(nameof(handler));
     }
     RegexMatch.Add(
         new Regex(BuildConsolidatedRegex(verb, path)),
         handler);
 }
コード例 #5
0
        public DrawMatches(int width, int height)
        {
            WIDTH  = width;
            HEIGHT = height;

            _modelImages = new Dictionary <string, Mat>();
            // _modelFeatures = new Dictionary<string, FeatureModel>();
            _modelMatcher = new Dictionary <string, Matcher>();
            foreach (var path in b)
            {
                int fileCount = Directory.GetFiles("resources/" + path + "/", "*.*", SearchOption.AllDirectories).Length;
                for (int i = 0; i < fileCount; i++)
                {
                    var bill       = "resources/" + path + "/" + i.ToString().PadLeft(4, '0') + ".png";
                    Mat modelImage = CvInvoke.Imread(bill, ImreadModes.Grayscale);
                    // CvInvoke.Resize(modelImage, modelImage, new Size(WIDTH, HEIGHT));
                    var matcher = new Matcher();
                    _modelImages.Add(path + "_" + i.ToString(), modelImage);
                    matcher.Add(ExtractFeatures(modelImage));
                    _modelMatcher.Add(path + "_" + i.ToString(), matcher.Train());
                }
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: juergs/RegexMatcher
        static void Main(string[] args)
        {
            string userInput;
            object val;

            // preload a few
            _Matcher.Add(new Regex("^/foo/\\d+$"), "foo with id");
            _Matcher.Add(new Regex("^/foo/?$"), "foo with optional slash");
            _Matcher.Add(new Regex("^/foo$"), "foo alone");
            _Matcher.Add(new Regex("^/bar/(.*?)/(.*?)/?$"), "bar with two children");
            _Matcher.Add(new Regex("^/bar/(.*?)/?$"), "bar with one child");
            _Matcher.Add(new Regex("^/bar/\\d+$"), "bar with id");
            _Matcher.Add(new Regex("^/bar/?$"), "bar with optional slash");
            _Matcher.Add(new Regex("^/bar$"), "bar alone");

            while (_RunForever)
            {
                Console.Write("Command [? for help] > ");
                userInput = Console.ReadLine();
                if (String.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                switch (userInput)
                {
                case "q":
                    _RunForever = false;
                    break;

                case "?":
                    Menu();
                    break;

                case "pref":
                    Console.Write("Preference [First|LongestFirst|ShortestFirst]: ");
                    _Matcher.MatchPreference = (MatchPreferenceType)(Enum.Parse(typeof(MatchPreferenceType), Console.ReadLine()));
                    break;

                case "add":
                    _Matcher.Add(
                        new Regex(InputString("Regex:", null, false)),
                        InputString("Value", null, true));
                    break;

                case "del":
                    _Matcher.Remove(
                        new Regex(InputString("Regex:", null, false)));
                    break;

                case "exists":
                    Console.WriteLine("Exists: " +
                                      _Matcher.Exists(
                                          new Regex(InputString("Regex:", null, false))));
                    break;

                case "valexists":
                    Console.WriteLine("Exists: " +
                                      _Matcher.ValueExists(
                                          InputString("Value:", null, true)));
                    break;

                case "match":
                    if (_Matcher.Match(
                            InputString("Input value:", null, false),
                            out val))
                    {
                        Console.Write("Match found: ");
                        if (val == null)
                        {
                            Console.WriteLine("(null)");
                        }
                        else
                        {
                            Console.WriteLine(val.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("No match found");
                    }
                    break;

                case "list":
                    Dictionary <Regex, object> matches = _Matcher.Get();
                    if (matches != null && matches.Count > 0)
                    {
                        Console.WriteLine("Added:");
                        foreach (KeyValuePair <Regex, object> curr in matches)
                        {
                            Console.WriteLine("  " + curr.Key.ToString() + ": " + curr.Value);
                        }
                        Console.WriteLine();
                    }
                    break;
                }
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: danceink123/RegexMatcher
        static void Main(string[] args)
        {
            Matcher matcher    = new Matcher();
            bool    runForever = true;
            string  userInput;
            object  val;

            // preload a few
            matcher.Add(new Regex("^/foo/\\d+$"), "foo with id");
            matcher.Add(new Regex("^/foo/?$"), "foo with optional slash");
            matcher.Add(new Regex("^/foo$"), "foo alone");
            matcher.Add(new Regex("^/bar/(.*?)/(.*?)/?$"), "bar with two children");
            matcher.Add(new Regex("^/bar/(.*?)/?$"), "bar with one child");
            matcher.Add(new Regex("^/bar/\\d+$"), "bar with id");
            matcher.Add(new Regex("^/bar/?$"), "bar with optional slash");
            matcher.Add(new Regex("^/bar$"), "bar alone");

            while (runForever)
            {
                Console.Write("Command [? for help] > ");
                userInput = Console.ReadLine();
                if (String.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                switch (userInput)
                {
                case "q":
                    runForever = false;
                    break;

                case "?":
                    Menu();
                    break;

                case "add":
                    matcher.Add(
                        new Regex(InputString("Regex", null, false)),
                        InputString("Value", null, true));
                    break;

                case "del":
                    matcher.Remove(
                        new Regex(InputString("Regex", null, false)));
                    break;

                case "exists":
                    Console.WriteLine("Exists: " +
                                      matcher.Exists(
                                          new Regex(InputString("Regex", null, false))));
                    break;

                case "valexists":
                    Console.WriteLine("Exists: " +
                                      matcher.ValueExists(
                                          InputString("Value", null, true)));
                    break;

                case "match":
                    if (matcher.Match(
                            InputString("Input value", null, false),
                            out val))
                    {
                        Console.Write("Match found: ");
                        if (val == null)
                        {
                            Console.WriteLine("(null)");
                        }
                        else
                        {
                            Console.WriteLine(val.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("No match found");
                    }
                    break;
                }
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            _Matcher = new Matcher();

            while (_RunForever)
            {
                Console.Write("Command [? for help] > ");
                string userInput = Console.ReadLine();
                if (String.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                userInput = userInput.ToLower().Trim();

                if (userInput.Equals("?"))
                {
                    Menu();
                }
                else if (userInput.Equals("q"))
                {
                    _RunForever = false;
                }
                else if (userInput.StartsWith("add "))
                {
                    string[] addParam = userInput.Split(' ');
                    if (addParam.Length != 3)
                    {
                        continue;
                    }
                    _Matcher.Add(addParam[1], addParam[2]);
                }
                else if (userInput.StartsWith("del "))
                {
                    string[] delParam = userInput.Split(' ');
                    if (delParam.Length != 2)
                    {
                        continue;
                    }
                    _Matcher.Remove(delParam[1]);
                }
                else if (userInput.StartsWith("exists "))
                {
                    string[] existsParam = userInput.Split(' ');
                    if (existsParam.Length != 3)
                    {
                        continue;
                    }
                    if (_Matcher.Exists(existsParam[1], existsParam[2]))
                    {
                        Console.WriteLine(existsParam[1] + " " + existsParam[2] + " exists");
                    }
                    else
                    {
                        Console.WriteLine(existsParam[1] + " " + existsParam[2] + " does not exist");
                    }
                }
                else if (userInput.StartsWith("match "))
                {
                    string[] matchParam = userInput.Split(' ');
                    if (matchParam.Length != 2)
                    {
                        continue;
                    }
                    if (_Matcher.MatchExists(matchParam[1]))
                    {
                        Console.WriteLine(matchParam[1] + " matches");
                    }
                    else
                    {
                        Console.WriteLine(matchParam[1] + " does not match");
                    }
                }
                else
                {
                    continue;
                }
            }
        }