/// <summary>
 /// Constructor.
 /// </summary>
 internal MarkupExtensionParser(
     IParserHelper    parserHelper,
     ParserContext    parserContext)
 {
     _parserHelper = parserHelper;
     _parserContext = parserContext;
 }
Exemple #2
0
 /// <summary>
 /// Construtor padrão
 /// </summary>
 /// <param name="business">Negócios</param>
 /// <param name="dbContext">Contexto de banco de dados</param>
 /// <param name="logger">Logger</param>
 /// <param name="parserHelper">Parser Helper</param>
 public MeService(
     IMeBusiness business,
     IDbContext dbContext,
     ILogger <AuthService> logger,
     IParserHelper parserHelper)
 {
     _business     = business;
     _dbContext    = dbContext?.CurrentDbContext;
     _logger       = logger;
     _parserHelper = parserHelper;
 }
Exemple #3
0
        /// <summary>
        /// Parse a text reader one word at a time.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="text"></param>
        /// <param name="func"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public Task <long> ParserAsync(IParserHelper helper, string text, Func <string, bool> func, CancellationToken token)
        {
            // split the line into words.
            var words = Regex.Matches(text, _pattern)
                        .OfType <Match>()
                        .Select(m => m.Value)
                        .Distinct()
                        .ToArray();

            return(helper.AddWordsAsync(func == null ? words.ToList() : words.Where(func).ToList(), token));
        }
        /// <summary>
        /// Construtor padrão
        /// </summary>
        public ParserHelperTests()
        {
            ServiceCollection services = new ServiceCollection();

            services.AddSingleton <IParserHelper, ParserHelper>(impl =>
            {
                return(new ParserHelper(new Mocks.MockLogger <ParserHelper>()));
            });

            _parserHelper = services.BuildServiceProvider().GetService <IParserHelper>();
        }
Exemple #5
0
 /// <summary>
 /// Parse a given file.
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="token"></param>
 /// <param name="func">The function that tells us if we can add a word or not.</param>
 /// <returns></returns>
 public async Task <long> ParserAsync(IParserHelper helper, Func <string, bool> func, CancellationToken token)
 {
     // open non-locking file stream
     using (var fs = new FileStream(helper.File.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         using (var sr = new StreamReader(fs))
         {
             return(await ParserAsync(helper, sr, func, token).ConfigureAwait(false));
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// Parse a text reader one word at a time.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="sr"></param>
        /// <param name="func"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <long> ParserAsync(IParserHelper helper, TextReader sr, Func <string, bool> func, CancellationToken token)
        {
            // the number of words we added.
            long added = 0;

            // the word
            string text;

            while ((text = await ReadTextAsync(sr, token).ConfigureAwait(false)) != null)
            {
                token.ThrowIfCancellationRequested();

                added += await ParserAsync(helper, text, func, token).ConfigureAwait(false);
            }

            // did we find anything?
            return(added);
        }
Exemple #7
0
        /// <summary>
        /// Extensão que configura o Handler para tratamento de erros
        /// </summary>
        /// <param name="app">Applicação</param>
        public static IApplicationBuilder ConfigureDefaultExceptionHandler(
            this IApplicationBuilder app)
        {
            IParserHelper parserHelper = app.ApplicationServices.GetRequiredService <IParserHelper>();

            app
            .UseMiddleware <Middleware.UnhandledExceptionMiddleware>()
            .UseExceptionHandler(config =>
            {
                config.Run(async context =>
                {
                    IExceptionHandlerFeature error = context.Features.Get <IExceptionHandlerFeature>();
                    if (error != null)
                    {
                        context.Response.StatusCode = error.Error switch
                        {
                            UnauthorizedAccessException unauthorizedAccessException => StatusCodes.Status401Unauthorized,
                            _ => StatusCodes.Status400BadRequest,
                        };

                        if (context.Response.StatusCode != StatusCodes.Status401Unauthorized)
                        {
                            context.Response.ContentType = "application/json";

                            ViewModel.ApiErrorResponse apiError = new ViewModel.ApiErrorResponse();
                            apiError.Errors.Add(new ViewModel.ApiErrorDetailResponse());

                            await context.Response.WriteAsync(parserHelper.ToJson(apiError)).ConfigureAwait(false);
                        }
                    }
                });
            })
            .UseHsts();

            return(app);
        }
Exemple #8
0
 public OnAck(INetworkingManager <DataWithAttributes> network_manager)
 {
     this._network_manager = network_manager;
     _parser_helper        = new JsonParserHelper();
 }
Exemple #9
0
 /// <inheritdoc />
 public Task <long> ParseAsync(IParserHelper helper, ILogger logger, CancellationToken token)
 {
     return(_parser.ParserAsync(helper, Contains, token));
 }
 internal Extract(IParserHelper parserHelper, IMatch match)
 {
     _parserHelper = parserHelper;
     _match        = match;
 }
 internal Match(IParserHelper parserHelper)
 {
     _parserHelper = parserHelper;
 }
 public Dev2DataLanguageParser(IParserHelper parserHelper)
 {
     _parserHelper       = parserHelper;
     _dataLanguageParser = new DataLanguageParserImplementation(_parserHelper, this);
 }
 internal DataLanguageParserImplementation(IParserHelper parserHelper, IDev2DataLanguageParser dev2DataLanguageParser, IExtract extract)
 {
     _parserHelper           = parserHelper;
     _dev2DataLanguageParser = dev2DataLanguageParser;
     _extract = extract;
 }
 public DataLanguageParserImplementation(IParserHelper parserHelper, IDev2DataLanguageParser dev2DataLanguageParser)
     : this(parserHelper, dev2DataLanguageParser, new Extract(parserHelper, new Match(parserHelper)))
 {
 }
 /// <inheritdoc />
 public Task <long> ParseAsync(IParserHelper helper, ILogger logger, CancellationToken token)
 {
     return(_parser.ParserAsync(helper, StripCSharpWords, token));
 }
 // Token: 0x060021AC RID: 8620 RVA: 0x000A7BF5 File Offset: 0x000A5DF5
 internal MarkupExtensionParser(IParserHelper parserHelper, ParserContext parserContext)
 {
     this._parserHelper  = parserHelper;
     this._parserContext = parserContext;
 }