Пример #1
0
        public void ReadNamespaceConformity()
        {
            NamespaceConformities = new List <NamespaceConformity>();

            string filename;

            if (!string.IsNullOrEmpty(Settings.Default.BotConfiguration))
            {
                filename = Settings.Default.Namespaces;
            }
            else
            {
                filename = "Namespaces.txt";
            }

            string text;

            try
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    text = sr.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return;
            }

            MatchCollection matches = _nsRegex.Matches(text);

            foreach (Match m in matches)
            {
                var nc = new NamespaceConformity
                {
                    Lang1 = m.Groups[1].Value,
                    Lang2 = m.Groups[3].Value
                };
                if (!int.TryParse(m.Groups[2].Value, out nc.Ns1))
                {
                    continue;
                }
                if (!int.TryParse(m.Groups[4].Value, out nc.Ns2))
                {
                    continue;
                }

                NamespaceConformities.Add(nc);
            }
        }
Пример #2
0
        public void ReadNamespaceConformity()
        {
            NamespaceConformities = new List<NamespaceConformity>();

            string filename;

            if (!string.IsNullOrEmpty(Settings.Default.BotConfiguration))
                filename = Settings.Default.Namespaces;
            else
                filename = "Namespaces.txt";

            string text;
            try
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    text = sr.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return;
            }

            MatchCollection matches = _nsRegex.Matches(text);
            foreach (Match m in matches)
            {
                var nc = new NamespaceConformity
                    {
                        Lang1 = m.Groups[1].Value,
                        Lang2 = m.Groups[3].Value
                    };
                if (!int.TryParse(m.Groups[2].Value, out nc.Ns1))
                    continue;
                if (!int.TryParse(m.Groups[4].Value, out nc.Ns2))
                    continue;

                NamespaceConformities.Add(nc);
            }
        }