Skip to content

Instantly share code, notes, and snippets.

@nbxx
nbxx / project.json
Last active September 17, 2016 02:23
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
// delete this line: "type": "platform",
"version": "1.0.0-rc2-*"
}
public static object CreateInstanceGeneric(Type source, Type[] typeArguments, params object[] args)
{
object result = null;
Type genericType = source.MakeGenericType(typeArguments);
try
{
result = Activator.CreateInstance(genericType, args);
}
public static object CreateInstance(Type source, params object[] args)
{
if (source == typeof(string))
{
return string.Empty;
}
object result = null;
try
public static object CreateInstance(Type type)
{
return Activator.CreateInstance(type);
}
public static object CreateInstance(Type type)
{
return type.GetConstructor(new Type[] { }).Invoke(new object[] { });
}
<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>
@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
{
@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 / 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 / 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();