Skip to content

Instantly share code, notes, and snippets.

View cammerman's full-sized avatar

Chris Ammerman cammerman

View GitHub Profile
@cammerman
cammerman / Bootstrap.cs
Created November 16, 2010 04:46
Setting provider types for injecting simple setting values
namespace Bootstrap
{
using Autofac;
using Autofac.Builder;
using System.Reflection;
public static class AutofacBootstrap
{
public static IContainer BootstrapIoC()
{
@cammerman
cammerman / DocumentStream.cs
Created November 17, 2010 13:37
Class with multiple constructors having both latent and contextual dependencies
public class DocumentStream
{
public DocumentStream(ISeparationStrategy separator, IPageStream pageStream)
{
// ...
}
public DocumentStream(ISeparationStrategy separator, IEnumerable<IPage> pageList)
{
@cammerman
cammerman / ContextualDef.cs
Created November 30, 2010 03:06
Autofac Blog Post Samples
interface IComparisonWindow { /* ... */ }
class ComparisonWindow : IComparisonWindow { /* ... */ }
enum EComparisonSide
{
Left,
Right
}
@cammerman
cammerman / FolderTransformService1.cs
Created January 8, 2011 23:50
Generated boilerplate service class.
public partial class FolderTransformService : ServiceBase
{
public FolderTransformService()
{
InitializeComponent();
}
protected override void OnStart(String[] args)
{
}
@cammerman
cammerman / Program.cs
Created January 23, 2011 21:47
Service example VS2008 generated boilerplate
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
@cammerman
cammerman / InstallBootstrapper.cs
Created February 7, 2011 01:26
IoC Boostrappers, version 1
internal class InstallBootstrapper
{
public IContainer Build()
{
var builder = new ContainerBuilder();
return builder.Build();
}
}
@cammerman
cammerman / ProjectInstaller.cs
Created February 7, 2011 01:40
ProjectInstaller code file
using System.Configuration.Install;
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
public ProjectInstaller()
{
var bootstrapper = new InstallBootstrapper();
var container = bootstrapper.Build();
using System.Configuration.Install;
using System.ServiceProcess;
namespace HelloSvc.Services
{
internal class GreetServiceInstaller : ServiceInstaller
{
public GreetServiceInstaller()
: base()
{
@cammerman
cammerman / InstallBootstrapper.cs
Created February 7, 2011 02:11
Install bootstrapper v2
using System.ServiceProcess;
using System.Configuration.Install;
using Autofac;
namespace HelloSvc
{
using Install;
internal class InstallBootstrapper
@cammerman
cammerman / Program.cs
Created February 7, 2011 02:57
Service app mainline
using System.ServiceProcess;
using Autofac;
namespace HelloSvc
{
public static class Program
{
public static void Main(String[] args)
{