Skip to content

Instantly share code, notes, and snippets.

@nbxx
nbxx / FirstSolution.cs
Last active January 28, 2016 20:28
YouCanHackIt.ArchitectureDesign.DI.FirstSolution
namespace YouCanHackIt.ArchitectureDesign.DI.FirstSolution
{
using System;
public class Implementation
{
public void BuyProducts()
{
var importedCD = new Product("imported CD", 10.99m, false, true);
var perfume = new Product("perfume", 19.99m, false, false);
@nbxx
nbxx / SecondSolution.cs
Last active January 28, 2016 20:27
YouCanHackIt.ArchitectureDesign.DI.SecondSolution
namespace YouCanHackIt.ArchitectureDesign.DI.SecondSolution
{
using System;
using System.Collections.Generic;
using System.Linq;
public class Implementation
{
public void BuyProducts()
{
@nbxx
nbxx / SetterInjection.cs
Last active January 23, 2016 00:48
YouCanHackIt.ArchitectureDesign.DI.Samples.SetterInjection
namespace YouCanHackIt.ArchitectureDesign.DI.Samples
{
public class SetterInjection
{
public void Run()
{
ICalculator calculator1 = new DefaultTaxCalculator();
ICalculator calculator2 = new FoodTaxCalculator();
ICalculator calculator3 = new BookTaxCalculator();
@nbxx
nbxx / ConstructorInjection.cs
Created January 23, 2016 00:47
YouCanHackIt.ArchitectureDesign.DI.Samples.ConstructorInjection
namespace YouCanHackIt.ArchitectureDesign.DI.Samples
{
public class ConstructorInjection
{
public void Run()
{
ICalculator calculator1 = new DefaultTaxCalculator();
ICalculator calculator2 = new FoodTaxCalculator();
ICalculator calculator3 = new BookTaxCalculator();
@nbxx
nbxx / ThirdSolution.cs
Last active January 29, 2016 20:49
YouCanHackIt.ArchitectureDesign.DI.ThirdSolution
namespace YouCanHackIt.ArchitectureDesign.DI.ThirdSolution
{
using System;
using System.Collections.Generic;
using System.Linq;
public class Implementation
{
public void BuyProducts()
{
@nbxx
nbxx / MEFSolution.cs
Last active January 29, 2016 20:49
YouCanHackIt.ArchitectureDesign.DI.MEFSolution
namespace YouCanHackIt.ArchitectureDesign.DI.MEFSolution
{
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Reflection;
public class Implementation
@nbxx
nbxx / DevLibSolution.cs
Created January 29, 2016 20:48
YouCanHackIt.ArchitectureDesign.DI.DevLibSolution
namespace YouCanHackIt.ArchitectureDesign.DI.DevLibSolution
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DevLib.Ioc;
public class Implementation
{
<sdk:sdk-addon>
<sdk:add-on>
<sdk:revision>18</sdk:revision>
<sdk:archives>
<sdk:archive>
<sdk:size>224779548</sdk:size>
<sdk:checksum type="sha1">E2B81A62720BB1735C0B4CD8CEF5D861FFF9CEE9</sdk:checksum>
<sdk:url>addon-google_apis_x86-google-19.zip</sdk:url>
</sdk:archive>
</sdk:archives>
public static object CreateInstance(Type type)
{
return type.GetConstructor(new Type[] { }).Invoke(new object[] { });
}
public static object CreateInstance(Type type)
{
return Activator.CreateInstance(type);
}