Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / 1-IAccountService.cs
Created March 17, 2019 10:59
Multi-Tenant Solutions - IAccountService.cs
public interface IAccountService {
IEnumerable<AccountPmo> List();
AccountPmo Get(string guid);
AccountPmo Save(AccountPmo model);
AccountPmo Delete(string guid);
}
public class StreamServer : IDisposable
{
static Serilog.ILogger Log = Serilog.Log.ForContext<StreamServer>();
private const byte ACK = 0x06;
private const byte NAK = 0x15;
private const string HOST_TO_TERMINAL = "[Host->Terminal]";
private const string TERMINAL_TO_HOST = "[Terminal->Host]";
private const byte STX = 0x02;
private const byte ETX = 0x03;
private const string ACK_STR = "<ACK>";
@dealproc
dealproc / DocumentConverter.cs
Created April 21, 2020 18:17
System.Text.Json parser for slip-based messaging documents
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace YourNamespace {
@dealproc
dealproc / Converter.cs
Created May 3, 2020 01:09
System.Text.Json ValueConverter
public class ValueObjectConverter : JsonConverterFactory
{
public override bool CanConvert(Type typeToConvert)
{
if (typeToConvert.BaseType == null) return false;
if (!typeToConvert.BaseType.IsGenericType) return false;
if (typeToConvert.BaseType.GetGenericTypeDefinition() != typeof(ValueObject<>)) return false;
return true;
}
@dealproc
dealproc / ServiceBase.cs
Created October 27, 2022 20:50
ServiceBase for ReactiveDomain
public class ServiceBase : IHandle<IMessage>,
IPublisher, IDisposable {
private readonly Func<IListener> _getListener;
private readonly List<IListener> _listeners = new();
private readonly InMemoryBus _bus;
private readonly QueuedHandler _queue;
private readonly List<IDisposable> _disposables = new();
public ServiceBase(string name, ISubscriber inBus, IPublisher outBus, IConfiguredConnection connection) : this(name, inBus, outBus, () => connection.GetQueuedListener(name)) {
}