dotnetcoding
dotnetcoding
Objective: Develop a custom middleware in ASP.NET Core that logs incoming HTTP
requests and measures the time taken to process each request. The middleware should
log the following details:
Requirements:
Middleware Implementation:
Create a class named RequestLoggingMiddleware that handles the logging
logic.
Implement the InvokeAsync method to capture request and response details.
Performance Measurement:
Record the time taken to process each request using a high-resolution
timer.
Logging:
Use ASP.NET Core's built-in logging framework (ILogger) to log the
information.
Ensure that logs are written in a structured format for easy analysis.
Registration:
Configure the middleware in the ASP.NET Core request pipeline within the
Startup class.
Considerations:
======================
1. Implement a Thread-Safe Singleton Pattern
Task: Design a singleton class in C# that ensures thread safety without using
language-level constructs like lock. The implementation should be lazy-initialized
and performant.
Requirements:
Ensure that only one instance of the class is created, even in a multithreaded
environment.
=====================
Develop a Custom LINQ Extension Method
Task: Create a LINQ extension method named Batch that processes a collection in
batches of a specified size. The method should yield each batch as an
IEnumerable<T>.
Requirements:
Example usage
Create a function to receive a string from console and then remove duplicate
characters from the string and reprint the unique string
Create a function which receives two strings and find if they are anagrams