Skip to content

Instantly share code, notes, and snippets.

View davybrion's full-sized avatar

Davy Brion davybrion

  • That Extra Mile
  • Belgium
View GitHub Profile
@davybrion
davybrion / s1.xml
Created September 10, 2012 19:45
code snippets for "Consuming Multiple Agatha Services" post
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="firstServiceBinding"
contract="Agatha.Common.WCF.IWcfRequestProcessor"
name="firstService" />
<endpoint binding="basicHttpBinding" bindingConfiguration="secondServiceBinding"
contract="Agatha.Common.WCF.IWcfRequestProcessor"
name="secondService" />
</client>
@davybrion
davybrion / s1.cs
Created September 10, 2012 19:40
code snippets for "Avoiding Leaking Connections With NHibernate And TransactionScope" post
[TestFixture]
public class ConnectionLeakTest
{
private static ISessionFactory sessionFactory;
static ConnectionLeakTest()
{
sessionFactory = new Configuration()
.Configure()
.AddAssembly("MyAssembly")
@davybrion
davybrion / s1.cs
Created September 10, 2012 19:30
code snippets for "MSDTC Woes With NServiceBus And NHibernate" post
public class DummyEnlistmentNotification : IEnlistmentNotification
{
public static readonly Guid Id = new Guid("E2D35055-4187-4ff5-82A1-F1F161A008D0");
public void Prepare(PreparingEnlistment preparingEnlistment)
{
preparingEnlistment.Prepared();
}
public void Commit(Enlistment enlistment)
@davybrion
davybrion / s1.cs
Created September 10, 2012 19:26
code snippets for "Using Copy-On-Write In Multithreaded Code To Reduce Locking Overhead" post
public class TenantSessionFactoryManager : ITenantSessionFactoryManager
{
private readonly ITenantContext tenantContext;
private readonly ITenantInfoHolder tenantInfoHolder;
private readonly string mappingAssemblyName;
private readonly object writeLock = new object();
private Dictionary<Guid, ISessionFactory> sessionFactories;
public TenantSessionFactoryManager(ITenantContext tenantContext, ITenantInfoHolder tenantInfoHolder, string mappingAssemblyName)
@davybrion
davybrion / s1.cs
Created September 10, 2012 19:17
code snippet for "wanna review my code" post
public class TenantSessionFactoryManager : ITenantSessionFactoryManager
{
private readonly ITenantContext tenantContext;
private readonly ITenantInfoHolder tenantInfoHolder;
private readonly string mappingAssemblyName;
private readonly object writeLock = new object();
private Dictionary<Guid, ISessionFactory> sessionFactories;
public TenantSessionFactoryManager(ITenantContext tenantContext, ITenantInfoHolder tenantInfoHolder, string mappingAssemblyName)
@davybrion
davybrion / s1.cs
Created September 10, 2012 19:08
code snippets for "Securing Your Agatha Service Layer" post
public class MyProjectRequest : Request
{
public string UserName { get; set; }
public byte[] PasswordHash { get; set; }
}
public class MyProjectResponse : Response {}
@davybrion
davybrion / s1.cs
Created September 10, 2012 18:56
code snippets for "Is There A Good Reason To Hide Inherited Members?" post
public class MyClass
{
public void DoSomething()
{
Console.WriteLine("i'm doing something important");
}
}
@davybrion
davybrion / s1.cs
Created September 10, 2012 18:47
code snippet for "Inversion Of Control Containers And Factories Aren’t Mutually Exclusive" post
public interface IAsyncRequestDispatcherFactory
{
IAsyncRequestDispatcher CreateAsyncRequestDispatcher();
}
public class AsyncRequestDispatcherFactory : IAsyncRequestDispatcherFactory
{
public IAsyncRequestDispatcher CreateAsyncRequestDispatcher()
{
return IoC.Container.Resolve<IAsyncRequestDispatcher>();
@davybrion
davybrion / s1.cs
Created September 10, 2012 18:41
code snippets for "Hey Microsoft, Our Databases Aren’t Services!" post
// Implements application logic using the ChinookEntities context.
// TODO: Add your application logic to these methods or in additional methods.
// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
// Also consider adding roles to restrict access as appropriate.
// [RequiresAuthentication]
[EnableClientAccess()]
public class AlbumService : LinqToEntitiesDomainService<ChinookEntities>
{
// TODO: Consider
@davybrion
davybrion / s1.cs
Created September 9, 2012 17:06
code snippets for "Unit Testing An NHibernate Application" post
public class NHibernateTest
{
private Configuration configuration;
protected ISessionFactory sessionFactory;
[TestFixtureSetUp]
public void TestFixtureSetup()
{
configuration = new Configuration()
.Configure()