-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
236 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
samples/src/Bytewizer.NanoCLR.DependencyInjection/Bytewizer.DependencyInjection.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.32112.339 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Bytewizer.DependencyInjection", "Bytewizer.DependencyInjection\Bytewizer.DependencyInjection.nfproj", "{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{375F2C37-EDCD-44FA-8BC7-72AED0A1C0DF}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {ABCA1850-E875-490C-AC83-3DBCC630ACB9} | ||
EndGlobalSection | ||
EndGlobal |
74 changes: 74 additions & 0 deletions
74
...LR.DependencyInjection/Bytewizer.DependencyInjection/Bytewizer.DependencyInjection.nfproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath> | ||
</PropertyGroup> | ||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<ProjectGuid>375f2c37-edcd-44fa-8bc7-72aed0a1c0df</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<FileAlignment>512</FileAlignment> | ||
<RootNamespace>Bytewizer.DependencyInjection</RootNamespace> | ||
<AssemblyName>Bytewizer.DependencyInjection</AssemblyName> | ||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" /> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="Bytewizer.NanoCLR.Core"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.Core.2.1.8\lib\Bytewizer.NanoCLR.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.DependencyInjection"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.DependencyInjection.2.1.8\lib\Bytewizer.NanoCLR.DependencyInjection.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.DependencyInjection.Abstractions"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.DependencyInjection.Abstractions.2.1.8\lib\Bytewizer.NanoCLR.DependencyInjection.Abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.Logging"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.Logging.2.1.8\lib\Bytewizer.NanoCLR.Logging.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.Logging.Abstractions"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.Logging.Abstractions.2.1.8\lib\Bytewizer.NanoCLR.Logging.Abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.Logging.Debug"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.Logging.Debug.2.1.8\lib\Bytewizer.NanoCLR.Logging.Debug.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bytewizer.NanoCLR.Logging.Extensions"> | ||
<HintPath>..\packages\Bytewizer.NanoCLR.Logging.Extensions.2.1.8\lib\Bytewizer.NanoCLR.Logging.Extensions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="mscorlib"> | ||
<HintPath>..\packages\nanoFramework.CoreLibrary.1.12.0-preview.5\lib\mscorlib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nanoFramework.Runtime.Events"> | ||
<HintPath>..\packages\nanoFramework.Runtime.Events.1.10.0-preview.6\lib\nanoFramework.Runtime.Events.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nanoFramework.System.Collections"> | ||
<HintPath>..\packages\nanoFramework.System.Collections.1.4.0-preview.14\lib\nanoFramework.System.Collections.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nanoFramework.System.Text"> | ||
<HintPath>..\packages\nanoFramework.System.Text.1.1.3-preview.13\lib\nanoFramework.System.Text.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.IO.FileSystem"> | ||
<HintPath>..\packages\nanoFramework.System.IO.FileSystem.1.0.3-preview.9\lib\System.IO.FileSystem.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Math"> | ||
<HintPath>..\packages\nanoFramework.System.Math.1.4.4-preview.13\lib\System.Math.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" /> | ||
<ProjectExtensions> | ||
<ProjectCapabilities> | ||
<ProjectConfigurationsDeclaredAsItems /> | ||
</ProjectCapabilities> | ||
</ProjectExtensions> | ||
</Project> |
76 changes: 76 additions & 0 deletions
76
samples/src/Bytewizer.NanoCLR.DependencyInjection/Bytewizer.DependencyInjection/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Threading; | ||
|
||
using Bytewizer.NanoCLR.Logging; | ||
using Bytewizer.NanoCLR.DependencyInjection; | ||
|
||
namespace Bytewizer.DependencyInjection | ||
{ | ||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
var serviceProvider = new ServiceCollection() | ||
.AddSingleton(typeof(ILoggerFactory), typeof(LoggerFactory)) | ||
.AddSingleton(typeof(IFooService), typeof(FooService)) | ||
.AddSingleton(typeof(IBarService), typeof(BarService)) | ||
.BuildServiceProvider(); | ||
|
||
var loggerFactory = (LoggerFactory)serviceProvider.GetService(typeof(ILoggerFactory)); | ||
loggerFactory.AddDebug(); | ||
|
||
var logger = loggerFactory.CreateLogger(typeof(Program)); | ||
logger.LogInformation("Starting application"); | ||
|
||
//do the actual work here | ||
var bar = (BarService)serviceProvider.GetService(typeof(IBarService)); | ||
bar.DoSomeRealWork(); | ||
|
||
logger.LogInformation("All done!"); | ||
} | ||
} | ||
|
||
public interface IFooService | ||
{ | ||
void DoThing(int number); | ||
} | ||
|
||
public interface IBarService | ||
{ | ||
void DoSomeRealWork(); | ||
} | ||
|
||
public class BarService : IBarService | ||
{ | ||
private readonly IFooService _fooService; | ||
|
||
public BarService(IFooService fooService) | ||
{ | ||
_fooService = fooService; | ||
} | ||
|
||
public void DoSomeRealWork() | ||
{ | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
_fooService.DoThing(i); | ||
} | ||
} | ||
} | ||
|
||
public class FooService : IFooService | ||
{ | ||
private readonly ILogger _logger; | ||
|
||
public FooService(ILoggerFactory loggerFactory) | ||
{ | ||
_logger = loggerFactory.CreateLogger(typeof(FooService)); | ||
} | ||
|
||
public void DoThing(int number) | ||
{ | ||
_logger.LogInformation($"Doing your thing {number}"); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...izer.NanoCLR.DependencyInjection/Bytewizer.DependencyInjection/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("CSharp.BlankApplication")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CSharp.BlankApplication")] | ||
[assembly: AssemblyCopyright("Copyright © ")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
16 changes: 16 additions & 0 deletions
16
...s/src/Bytewizer.NanoCLR.DependencyInjection/Bytewizer.DependencyInjection/packages.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Bytewizer.NanoCLR.Core" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.DependencyInjection" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.DependencyInjection.Abstractions" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.Logging" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.Logging.Abstractions" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.Logging.Debug" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="Bytewizer.NanoCLR.Logging.Extensions" version="2.1.8" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.CoreLibrary" version="1.12.0-preview.5" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.Runtime.Events" version="1.10.0-preview.6" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.System.Collections" version="1.4.0-preview.14" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.System.IO.FileSystem" version="1.0.3-preview.9" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.System.Math" version="1.4.4-preview.13" targetFramework="netnanoframework10" /> | ||
<package id="nanoFramework.System.Text" version="1.1.3-preview.13" targetFramework="netnanoframework10" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters