Ejemplo n.º 1
0
        private Parser(ParserArguments arguments)
        {
            _arguments   = arguments;
            _expressions = new Expressions(_arguments);

            _expressionText       = arguments.ExpressionText ?? string.Empty;
            _expressionTextLength = _expressionText.Length;
            SetTextPos(0);
            NextToken();
        }
Ejemplo n.º 2
0
        public void ParseArguments_IsValidCommandReplace_ReturnsTrue(params string[] args)
        {
            //arrange
            ParserArguments parserArguments = new ParserArguments();
            bool            expected        = true;
            //act
            bool actual = parserArguments.IsValidCommandReplace(args);

            //assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        public void ParseArguments_IsValidCommandCounting_ReturnsFalse(params string[] args)
        {
            //arrange
            ParserArguments parserArguments = new ParserArguments();
            bool            expected        = false;
            //act
            bool actual = parserArguments.IsValidCommandCounting(args);

            //assert
            Assert.Equal(expected, actual);
        }
        private Statistics Execute(ParserArguments parserArguments)
        {
            string fileName = @"Resources\PerfViewData.etl";

            using (var file = TraceLog.OpenOrConvert(fileName))
            {
                FakeViewer viewer = new FakeViewer();
                var        parser = new Parser(viewer);
                parser.Parse(file.Events, parserArguments);
                return(viewer.Stat);
            }
        }
Ejemplo n.º 5
0
		Parser(ParserArguments arguments)
		{
			_arguments = arguments;

			_bindingCase = arguments.Settings.CaseInsensitive ? BindingFlags.IgnoreCase : BindingFlags.Default;
			_memberFilterCase = arguments.Settings.CaseInsensitive ? Type.FilterNameIgnoreCase : Type.FilterName;

			_expressionText = arguments.ExpressionText ?? string.Empty;
			_expressionTextLength = _expressionText.Length;
			SetTextPos(0);
			NextToken();
		}
Ejemplo n.º 6
0
    public void CalculateStatistics(string etlFileName, string providerName, string startEvent, string stopEvent, string outputReport = "report.xlsx")
    {
        Parser parser = new Parser(GetViewer(outputReport));

        using (ETLDataFile etlFile = OpenETLFile(etlFileName))
        {
            ParserArguments arguments = new ParserArguments
            {
                ProviderName = providerName,
                StartEvent   = startEvent,
                StopEvent    = stopEvent,
                OutputReport = outputReport
            };

            TraceEvents events = GetTraceEventsWithProcessFilter(etlFile);
            parser.Parse(events, arguments);
        }
    }
        public StatsTestResult Should_Return_Correct_TotatlCount(String provider, String start, String finish)
        {
            ParserArguments arguments = new ParserArguments
            {
                ProviderName = provider,
                StartEvent   = start,
                StopEvent    = finish
            };

            var result = Execute(arguments);

            return(new StatsTestResult
            {
                TotalCount = result.TotalCount,
                MaxValue = result.MaxValue,
                MinVale = result.MinValue,
                StdDeviation = result.StdDeviation
            });
        }
Ejemplo n.º 8
0
		public static Expression Parse(ParserArguments arguments)
		{
			return new Parser(arguments).Parse();
		}
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            Log.WriteLine("Hello World!");
            List <IncomingArgsClass> arg_parser = new ParserArguments().Parse(args);

            if (!arg_parser.Exists(x => x.name_argument.ToLower() == "api_key_telegram_bot"))
            {
                Log.WriteLine("Отсутсвует API Telegram auth key", LogStatusEnum.Alarm);
                return;
            }

            anti_spam = new SpamBlock(arg_parser.SingleOrDefault(x => x.name_argument.ToLower() == "api_key_telegram_bot").value_argument);

            if (anti_spam.telegram_client.Me is null)
            {
                Log.WriteLine("Telegram бот не запущен. Проверьте подключение к интернету и api_key_telegram_bot", LogStatusEnum.Alarm);
                return;
            }

            if (arg_parser.Exists(x => x.name_argument.ToLower() == "bot_admin_username"))
            {
                anti_spam.BotAdminUsername = arg_parser.SingleOrDefault(x => x.name_argument.ToLower() == "bot_admin_username").value_argument;
                Log.WriteLine("bot_admin_username="******"Отсутсвует bot_admin_username. Некому управлять ботом в режиме Online", LogStatusEnum.Notice);
            }

            if (
                arg_parser.Exists(x => x.name_argument.ToLower() == "webhook_api_url") &&
                arg_parser.Exists(x => x.name_argument.ToLower() == "hmac_sign_key") &&
                arg_parser.Exists(x => x.name_argument.ToLower() == "hmac_sign_secret"))
            {
                anti_spam.SetWebhook(arg_parser.SingleOrDefault(x => x.name_argument.ToLower() == "webhook_api_url").value_argument, arg_parser.SingleOrDefault(x => x.name_argument.ToLower() == "hmac_sign_key").value_argument, arg_parser.SingleOrDefault(x => x.name_argument.ToLower() == "hmac_sign_secret").value_argument);
                Log.WriteLine("Установлен Webhook/HMAC > " + anti_spam.WebhookAddress, LogStatusEnum.Norma);
            }

            foreach (IncomingArgsClass arg in arg_parser.Where(x => x.name_argument.ToLower() == "block_text"))
            {
                anti_spam.block_strings.Add(arg.value_argument);
            }

            foreach (IncomingArgsClass arg in arg_parser.Where(x => x.name_argument.ToLower() == "block_regex"))
            {
                anti_spam.block_regexes.Add(arg.value_argument);
            }

            foreach (IncomingArgsClass arg in arg_parser.Where(x => x.name_argument.ToLower() == "alert_text"))
            {
                anti_spam.alert_strings.Add(arg.value_argument);
            }

            foreach (IncomingArgsClass arg in arg_parser.Where(x => x.name_argument.ToLower() == "alert_regex"))
            {
                anti_spam.alert_regexes.Add(arg.value_argument);
            }

            Check_telegram();
            Log.WriteLine("Завершение работы", LogStatusEnum.Trace);
            Environment.Exit(1);
        }
Ejemplo n.º 10
0
 public static Expression Parse(ParserArguments arguments)
 {
     return(new Parser(arguments).Parse());
 }
Ejemplo n.º 11
0
 public Expressions(ParserArguments arguments)
 {
     _bindingCase      = arguments.Settings.CaseInsensitive ? BindingFlags.IgnoreCase : BindingFlags.Default;
     _memberFilterCase = arguments.Settings.CaseInsensitive ? Type.FilterNameIgnoreCase : Type.FilterName;
 }
Ejemplo n.º 12
0
 public SequencesApp()
 {
     _parserArguments = new ParserArguments();
 }
Ejemplo n.º 13
0
 public FileParserApp(IFileParser fileParser)
 {
     _fileParser      = fileParser;
     _fileParserUI    = new FileParserUI();
     _parserArguments = new ParserArguments();
 }