Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / HostnameAccountAccessor.cs
Created March 17, 2019 07:05
Multi-Tenant Solutions - HostnameAccountAccessor.cs
public class HostnameAccountAccessor : IAccountAccessor {
static readonly ILog _log = LogProvider.For<HostnameAccountAccessor>();
readonly IAccountRepository _AccountRepository;
readonly IOwinContext _owinContext;
Guid _instanceID;
public Guid InstanceID { get { return _instanceID; } }
public HostnameAccountAccessor(IOwinContext owinContext, IAccountRepository accountRepository) {
_instanceID = Guid.NewGuid();
@dealproc
dealproc / ClaimsPrincipalAccountAccessor.cs
Created March 17, 2019 07:02
Multi-Tenant Solutions - ClaimsPrincipalAccountAccessor.cs
public class ClaimsPrincipalAccountAccessor : IAccountAccessor {
static readonly ILog _log = LogProvider.For<ClaimsPrincipalAccountAccessor>();
readonly IAccountRepository _AccountRepository;
readonly IOwinContext _owinContext;
public ClaimsPrincipalAccountAccessor(IOwinContext owinContext, IAccountRepository accountRepository) {
_owinContext = owinContext;
_AccountRepository=accountRepository;
}
@dealproc
dealproc / NancyContextAccountAccessor.cs
Created March 17, 2019 06:58
Multi-Tenant Solutions - NancyContextAccountAccessor.cs
public class NancyContextAccountAccessor : IAccountAccessor {
static readonly ILog _log = LogProvider.For<NancyContextAccountAccessor>();
readonly IAccountRepository _accountRepository;
readonly NancyContext _nancyContext;
public NancyContextAccountAccessor(IAccountRepository accountRepository, NancyContext nancyContext) {
_accountRepository = accountRepository;
_nancyContext = nancyContext;
}
@dealproc
dealproc / ITenantAccessor.cs
Last active March 17, 2019 06:54
Multi-Tenant Solutions - ITenantAccessor
public interface IAccountAccessor {
Account GetCurrentAccount();
}
@dealproc
dealproc / Dockerfile
Created October 24, 2018 07:47
Docker for dotnet core 2.1 with mono
FROM jetbrains/teamcity-agent
ENV MONO_VERSION 5.4.1.6
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN apt install apt-transport-https
RUN echo "deb http://download.mono-project.com/repo/ubuntu stable-xenial main" | tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update \
{
"version": "0.2.0",
"configurations": [
{
"name": "{your project}",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/{your project dll}.dll",
"sourceFileMap": {
@dealproc
dealproc / IBrokeredRequest.cs
Created April 7, 2018 16:29
CQS with MediatR
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
public interface INotificationWithIdentification : INotification
{
Guid RequestID { get; set; }
/// <summary>
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
@dealproc
dealproc / ICache.cs
Last active August 31, 2016 22:58
Caching (in-memory and redis)
using System;
namespace {yourapp}.Infrastructure.Caching {
public interface ICache {
/// <summary>
/// Determines whether the specified keyformat contains key.
/// </summary>
/// <param name="keyformat">The keyformat.</param>
/// <param name="arguments">The arguments.</param>
/// <returns></returns>
@dealproc
dealproc / program.cs
Created April 11, 2016 18:25
Keyed instances of object(s)
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Autofac;
namespace AFMetadata {
class Program {