Skip to content

Instantly share code, notes, and snippets.

@TryingToImprove
Last active March 22, 2016 12:31
Show Gist options
  • Save TryingToImprove/494dc73def916849eee0 to your computer and use it in GitHub Desktop.
Save TryingToImprove/494dc73def916849eee0 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.PlatformAbstractions;
namespace ConsoleApp1
{
public class Program
{
public static IServiceProvider ServiceProvider { get; private set; }
public Program(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}
static void Main(string[] args)
{
var a = PlatformServices.Default; // works
// ServiceProvider == nulls, so throwing
var re = ServiceProvider.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment; //for operating system, architecture and runtime info
var ae = ServiceProvider.GetService(typeof(IApplicationEnvironment)); //for application path, name, version, configuration info
}
}
}
{
"version": "1.0.0-*",
"description": "ConsoleApp1 Console Application",
"authors": [ "Oliver" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final"
},
"commands": {
"ConsoleApp1": "ConsoleApp1"
},
"frameworks": {
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment