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.cs
Created September 9, 2012 12:21
code snippets for "How To Write Testable ASP.NET UserControls", part I
public interface IViewPart
{
bool IsPostBack { get; }
IDictionary State { get; }
}
@davybrion
davybrion / s1.cs
Created September 9, 2012 12:24
code snippets for "How To Write Testable ASP.NET UserControls", part II
public class DummyViewPartController : PartController<IDummyViewPart>, IDummyViewPartController
{
public DummyViewPartController(IDummyViewPart viewPart) : base(viewPart) {}
public override void AddInitialRequests()
{
// add some initial requests to the IDispatcher
}
public override void GetInitialResponses()
@davybrion
davybrion / s1.cs
Created September 9, 2012 12:28
code snippets for "Ordering on joined columns/properties with NHibernate"
var query = DetachedCriteria.For<Product>()
.SetFetchMode("Category", FetchMode.Join);
@davybrion
davybrion / s1.sql
Created September 9, 2012 12:31
code snippets for "Populating entities from Stored Procedures with NHibernate"
ALTER PROCEDURE [dbo].[GetProductsByCategoryId]
@CategoryId int
AS
BEGIN
SET NOCOUNT ON;
SELECT [ProductID]
,[ProductName]
,[SupplierID]
,[CategoryID]
@davybrion
davybrion / s1.sql
Created September 9, 2012 12:34
code snippets for "Populating Entities With Associations From Stored Procedures With NHibernate" post
ALTER PROCEDURE [dbo].[GetProductsByCategoryId]
@CategoryId int
AS
BEGIN
SET NOCOUNT ON;
SELECT [Products].[ProductID] as "Product.ProductID"
,[Products].[ProductName] as "Product.ProductName"
,[Products].[SupplierID] as "Product.SupplierID"
,[Products].[CategoryID] as "Product.CategoryID"
@davybrion
davybrion / s1.cs
Created September 9, 2012 12:36
code snippet for "Why On Earth Would A Developer Do This?" post
public void Execute()
{
ArrayList empIds = PayrollDatabase.GetAllEmployeeIds();
foreach (int empId in empIds)
{
Employee employee = PayrollDatabase.GetEmployee(empId);
if (employee.IsPayDate(payDate))
{
@davybrion
davybrion / s1.cs
Created September 9, 2012 12:38
code snippet for "The component burden" post
public class Controller : IController
{
public IDependency Dependency { get; private set; }
public Controller(IDependency myDependency)
{
Dependency = myDependency;
}
public void Dispose()
@davybrion
davybrion / s1.cs
Created September 9, 2012 12:48
code snippets for "The Importance Of Releasing Your Components Through Windsor" post
public interface IController : IDisposable
{
bool Disposed { get; set; }
}
public class Controller : IController
{
public void Dispose()
{
Disposed = true;
@davybrion
davybrion / s1.cs
Created September 9, 2012 13:00
code snippets for "The Importance Of Releasing Your Components Through Windsor" post, part II
public void Dispose()
{
Dependency.Dispose();
Disposed = true;
}
@davybrion
davybrion / s1.cs
Created September 9, 2012 13:03
code snippets for "The Resolvable" post
public class Resolvable<T> : Disposable
{
private readonly T instance;
public Resolvable() : this(null) {}
public Resolvable(object argumentsAsAnonymousType)
{
if (argumentsAsAnonymousType == null)
{