Skip to content

Instantly share code, notes, and snippets.

public static object CreateInstance(Type source, params object[] args)
{
if (source == typeof(string))
{
return string.Empty;
}
object result = null;
try
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);
}
@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-*"
}
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace ConsoleApplication
{
public class Startup
{
public void Configure(IApplicationBuilder app)
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApplication
{
public class Startup
{
using System;
using Microsoft.AspNetCore.Mvc;
namespace ConsoleApplication
{
public class HomeController
{
[HttpGet("/{name}")]
public string Index(string name)
{
using Microsoft.AspNetCore.Mvc;
namespace ConsoleApplication
{
public class HomeController : Controller
{
[HttpGet("/{name}")]
public IActionResult Index(string name)
{
ViewBag.Name = name;
<html>
<head>
<title>Hello</title>
<head>
<body>Hello, @ViewBag.Name</body>
</html>
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
namespace ConsoleApplication
{
public class Program
{