Skip to content

Instantly share code, notes, and snippets.

View NDiiong's full-sized avatar
😀
Hi there!

duong.nb NDiiong

😀
Hi there!
View GitHub Profile
public static void AddAny(this IServiceCollection collection, Assembly assembly, Func<Type, bool> implementFactory, ServiceLifetime serviceLifetime)
{
var serviceTypes = assembly.GetTypes()
.Where(x => !x.IsAbstract && x.GetInterfaces().Any(IsAnyServiceInterface))
.ToList();
serviceTypes.ForEach(x => AddService(collection, x));
bool IsAnyServiceInterface(Type type)
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace DomainServices
{
public class DataBuilder<TIn, TOut> where TIn : class where TOut : class, new()
{
@SirRufo
SirRufo / AzureBlobFileClient.cs
Last active March 3, 2021 10:07
IFileClient
public class AzureBlobFileClient : IFileClient
{
private CloudBlobClient _blobClient;
public AzureBlobFileClient(string connectionString)
{
var account = CloudStorageAccount.Parse(connectionString);
_blobClient = account.CreateCloudBlobClient();
}
@ian-beer
ian-beer / RestClient.cs
Last active March 26, 2021 10:34
.Net RestClient
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
namespace HttpUtils
{
public static class RestClient
{
@tcavaletto
tcavaletto / RockSolidChurchTemplate.cs
Last active November 16, 2020 08:22
Rock Solid Church Template
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using com.centralaz.RoomManagement.Attribute;
using com.centralaz.RoomManagement.Model;
using com.centralaz.RoomManagement.ReportTemplates;
using iTextSharp.text;
using iTextSharp.text.pdf;
@keimpema
keimpema / TaskExtensions.cs
Created October 16, 2017 14:05
TaskExtensions
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Usenet.Extensions
{
public static class TaskExtensions
{
public static async Task<TResult> TimeoutAfter<TResult>(this Task<TResult> task, TimeSpan timeout)
{
@gongdo
gongdo / TaskExtensions.cs
Last active April 25, 2022 06:53
Task extensions for parallelism
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Gist
{
public static class TaskExtensions
{
@elanderson
elanderson / RequestResponseLoggingMiddleware.cs
Created February 7, 2017 12:46
Request Response Logging Middleware for ASP.NET Core
public class RequestResponseLoggingMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger _logger;
public RequestResponseLoggingMiddleware(RequestDelegate next,
ILoggerFactory loggerFactory)
{
_next = next;
_logger = loggerFactory
@JonCole
JonCole / Redis-BestPractices-General.md
Last active April 27, 2024 12:50
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@goncalo-oliveira
goncalo-oliveira / ParallelAsync.cs
Last active April 2, 2021 03:36
Async Parallel.ForEach
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MyNamespace
{
public static class ParallelAsync
{