Skip to content

Instantly share code, notes, and snippets.

View xsoheilalizadeh's full-sized avatar
🎆
Working

Soheil Alizadeh xsoheilalizadeh

🎆
Working
View GitHub Profile
using x.Infrastructure.MassTransit;
using MassTransit;
using MassTransit.Scheduling;
namespace x.Infrastructure;
public static class MasstransitSchedulerExtensions
{
public static IMessageScheduler CreateCustomMessageScheduler(this IBus bus, Guid id)
{
using System;
using static Domain.Result;
namespace Domain
{
public readonly struct Result
{
private readonly Result<int, StringError> _result => new Result<int, StringError>(0);
public int Value => _result.Value;
public readonly struct ReadOnlyElement
{
private readonly ReadOnlySpan<byte> LessThanSign => new[] {(byte) '<'};
private readonly ReadOnlySpan<byte> GreaterThanSign => new[] {(byte) '>'};
private readonly ReadOnlySpan<byte> CloseElementSign => new[] {(byte) '<', (byte) '/'};
private readonly ReadOnlySpan<byte> EqualSign => new[] {(byte) '='};
private readonly ReadOnlySpan<byte> DoubleQuote => new[] {(byte) '\"'};
private readonly ReadOnlySpan<byte> WhiteSpace => new[] {(byte) ' '};
class Program
{
private static IPEndPoint IPEndPoint = new IPEndPoint(IPAddress.Loopback, 8801);
private static TcpClient Client = new TcpClient(IPEndPoint);
static async Task Main(string[] args)
{
Console.WriteLine($"Started on {IPEndPoint}");
@xsoheilalizadeh
xsoheilalizadeh / Program.cs
Created January 1, 2020 08:43
Interlocked
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Interlocked
{
class Program
{
static void Main(string[] args)
{
@xsoheilalizadeh
xsoheilalizadeh / Startup.cs
Created August 12, 2019 06:09
ASP.NET Core Identity
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddIdentity<IdentityUser<int>, IdentityRole<int>>()
.AddUserStore<CustomUserStore>();
}
}
@xsoheilalizadeh
xsoheilalizadeh / CustomUserStore.cs
Created August 11, 2019 21:51
ASP.NET Core Identity
public class CustomUserStore : IUserStore<IdentityUser<int>>
{
private readonly List<IdentityUser<int>> _users;
public CustomUserStore()
{
_users = new List<IdentityUser<int>>();
}
public Task<IdentityResult> CreateAsync(IdentityUser<int> user, CancellationToken cancellationToken)
@xsoheilalizadeh
xsoheilalizadeh / Startup.cs
Last active August 11, 2019 21:43
ASP.NET Core Identity
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddIdentity<IdentityUser<int>, IdentityRole<int>>()
.AddEntityFrameworkStores<ApplicationDbContext>();
}
}
@xsoheilalizadeh
xsoheilalizadeh / CustomFromQueryAttribute.cs
Last active July 12, 2019 12:07
Strongly typed snake-case [FromQuery] in ASP.NET Core
public class CustomFromQueryAttribute : FromQueryAttribute
{
public CustomFromQuery(string name)
{
Name = name.ToSnakeCase();
}
}