This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static class CollectionExtensions | |
| { | |
| // public static ICollection<(TSource FirstItem, TSource SecondItem)> ZipIntersectBy<TSource, TKey>( | |
| // this ICollection<TSource> first, | |
| // ICollection<TSource> second, | |
| // Func<TSource, TKey> keySelector | |
| // ) | |
| // { | |
| // // solution #1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static class ReferenceExtensions | |
| { | |
| public static string GetReferenceForManagedType<TValue>(TValue value) => | |
| GCHandle.Alloc(value, GCHandleType.Pinned).AddrOfPinnedObject().ToString(); | |
| public static unsafe string GetReferenceForUnmanagedType<TValue>(ref TValue value) where TValue : unmanaged | |
| { | |
| fixed (TValue* pointer = &value) | |
| { | |
| return ((IntPtr)pointer).ToString(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @echo off | |
| :: change the path below to match your installed version | |
| SET WebStormPath=C:\Program Files\JetBrains\WebStorm 2017.2.2\bin\webstorm64.exe | |
| echo Adding file entries | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_SZ /v "" /d "Open with WebStorm" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f | |
| @reg add "HKEY_CLASSES_ROOT\*\shell\WebStorm\command" /t REG_SZ /v "" /d "%WebStormPath% \"%%1\"" /f | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class EfCoreDataStorageBroker : DbContext, IDataStorageBroker | |
| { | |
| public DbSet<Book> Books => Set<Book>(); | |
| public DbSet<User> Users => Set<User>(); | |
| private static DbContextOptions<EfCoreDataStorageBroker> GetOptions() | |
| { | |
| var optionsBuilder = new DbContextOptionsBuilder<EfCoreDataStorageBroker>(); | |
| optionsBuilder.UseInMemoryDatabase("Tigernet"); | |
| return optionsBuilder.Options; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// <summary> | |
| /// Defines methods for logger broker | |
| /// </summary> | |
| public interface ILoggerBroker | |
| { | |
| /// <summary> | |
| /// Formats and writes an critical log message | |
| /// </summary> | |
| /// <param name="messageTemplate">Log message template</param> | |
| /// <param name="arg0">Argument 0</param> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Initializing a mock object | |
| private readonly Mock<ILogger<BookService>> _loggerMock = new(); | |
| // Verifying a call | |
| _loggerMock.Verify(x => x.Log(It.IsAny<LogLevel>(), | |
| It.IsAny<EventId>(), | |
| It.Is<It.IsAnyType>((o, t) => o.ToString()!.Contains($"Book with id {id} was not found")), | |
| It.IsAny<Exception>(), | |
| It.IsAny<Func<It.IsAnyType, Exception, string>>()!), | |
| Times.Once); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | getFormattedDate(date: Date): string { | |
| date = new Date(date.toLocaleString()); | |
| const now = new Date(); | |
| const diff = now.getTime() - date.getTime(); | |
| // Time constants in milliseconds | |
| const minute = 60 * 1000; | |
| const hour = 60 * minute; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import type { ProblemDetails } from "@/models/resources/problemDetails"; | |
| export class ApiResponse<T> { | |
| public response: T | null; | |
| public error: ProblemDetails | null; | |
| public status: number; | |
| constructor(response: T | null, error: ProblemDetails | null, status: number) { | |
| this.response = response; | |
| this.error = error; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public interface ISecurityTokenService | |
| { | |
| string Generate(string id, SecurityTokenType type); | |
| bool Validate(string token, string id, SecurityTokenType type, TimeSpan expirationTime); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class HttpContextExtensions | |
| { | |
| #region Authentication | |
| public async static ValueTask<IEnumerable<AuthenticationScheme>> GetAuthenticationProviders(this HttpContext context) | |
| { | |
| var provider = context.RequestServices.GetService<IAuthenticationSchemeProvider>(); | |
| return provider is not null | |
| ? (await provider.GetAllSchemesAsync()).Where(x => !string.IsNullOrWhiteSpace(x.DisplayName)) | |
| : Enumerable.Empty<AuthenticationScheme>(); |