This file contains 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 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)) { | |
} |
This file contains 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 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; | |
} |
This file contains 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
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 { |
This file contains 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 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>"; |
This file contains 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 IAccountService { | |
IEnumerable<AccountPmo> List(); | |
AccountPmo Get(string guid); | |
AccountPmo Save(AccountPmo model); | |
AccountPmo Delete(string guid); | |
} |
This file contains 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 ISessionSource { | |
ISession CreateSession(); | |
} |
This file contains 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 NHibernateMultiTenantSessionSource : ISessionSource { | |
#region Static Members and Constructor. | |
static readonly object _FactorySyncRoot = new object(); | |
static readonly ConcurrentDictionary<string, ISessionFactory> _SessionFactories = new ConcurrentDictionary<string, ISessionFactory>(); | |
#endregion | |
readonly IConfigurationReader _configurationManager; | |
readonly IAccountAccessor _accountAccessor; | |
readonly string _connectionStringModel; | |
This file contains 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 abstract class Repository<T> : IRepository<T> { | |
protected readonly ISessionSource _SessionSource; | |
public Repository(ISessionSource sessionSource) { | |
if (sessionSource == null) { | |
throw new ArgumentNullException("sessionFactory"); | |
} | |
_SessionSource = sessionSource; | |
} |
This file contains 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 IRepository<T> : IProject<T> where T : class, new() { | |
T Get(int id); | |
T GetFirst(Expression<Func<T, bool>> condition); | |
IEnumerable<T> GetAll(); | |
T SaveOrUpdate(T entity); | |
IEnumerable<T> SaveOrUpdate(IEnumerable<T> entities); | |
void Delete(T item); | |
// other various operations on your repository of choice ... | |
} |
This file contains 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 NHibernateMultiTenantSessionSource : ISessionSource { | |
#region Static Members and Constructor. | |
static readonly object _FactorySyncRoot = new object(); | |
static readonly ConcurrentDictionary<string, ISessionFactory> _SessionFactories = new ConcurrentDictionary<string, ISessionFactory>(); | |
#endregion | |
readonly IConfigurationReader _configurationManager; | |
readonly IAccountAccessor _accountAccessor; | |
readonly string _connectionStringModel; | |
public NHibernateMultiTenantSessionSource(IConfigurationReader configurationManager, IAccountAccessor accountAccessor) { |
NewerOlder