Skip to content

Commit

Permalink
Updated samples with di project
Browse files Browse the repository at this point in the history
  • Loading branch information
bytewizer committed Feb 6, 2022
1 parent 97d6fb8 commit 2176663
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
-p:PackageOutputPath=\builds\artifacts
-p:BuildNumber="${{ steps.info.outputs.build }}"
-p:Copyright="${{ steps.info.outputs.copyright }}"
-p:VersionPrefix="2.1.8"
-p:VersionPrefix="2.1.9"
-p:VersionSuffix=preview.${{ steps.info.outputs.build }}
-p:Configuration=${env:CONFIGURATION}
-p:ContinuousIntegrationBuild=true
Expand All @@ -75,7 +75,7 @@ jobs:
-p:PackageOutputPath=\builds\artifacts
-p:BuildNumber="${{ steps.info.outputs.build }}"
-p:Copyright="${{ steps.info.outputs.copyright }}"
-p:VersionPrefix="2.1.8"
-p:VersionPrefix="2.1.9"
-p:VersionSuffix=preview.${{ steps.info.outputs.build }}
-p:Configuration=${env:CONFIGURATION}
-p:ContinuousIntegrationBuild=true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ This repo contains several runtime libraries built for [GHI Electronics TinyCLR
* [Testing Framework](https://github.com/bytewizer/runtime/tree/develop/src/assertions)
* [Logging Framework](https://github.com/bytewizer/runtime/tree/develop/src/logging)
* [Middleware Pipeline](https://github.com/bytewizer/runtime/tree/develop/src/pipeline)
* [Dependency Injection (DI)](https://github.com/bytewizer/runtime/tree/develop/src/di)
* [Deflate, Zip, Gzip Compression](https://github.com/bytewizer/runtime/tree/develop/src/compression)
* [Identity Management - TinyCLR Only**](https://github.com/bytewizer/runtime/tree/develop/src/identity)
* [Dependency Injection (DI)](https://github.com/bytewizer/runtime/tree/develop/src/di)

**Note: Incompatible api footprints are bing researched between the two platforms. Other libraries will be updated as incompatibilities are worked around.

Expand Down
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
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>
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}");
}
}
}
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")]
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>
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
<ItemGroup>
<Folder Include="DependencyInjection\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\core\Bytewizer.NanoCLR.Core\Bytewizer.NanoCLR.Core.nfproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.5\lib\mscorlib.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<Folder Include="DependencyInjection\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\core\Bytewizer.NanoCLR.Core\Bytewizer.NanoCLR.Core.nfproj" />
<ProjectReference Include="..\Bytewizer.NanoCLR.DependencyInjection.Abstractions\Bytewizer.NanoCLR.DependencyInjection.Abstractions.nfproj" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
<tags>nanoframework nanoclr iot</tags>
<dependencies>
<dependency id="nanoFramework.CoreLibrary" version="1.12.0-preview.5" />
<dependency id="Bytewizer.NanoCLR.Core" version="2.1.8" />
<dependency id="Bytewizer.NanoCLR.DependencyInjection.Abstractions" version="2.1.8" />
<dependency id="nanoFramework.System.Math" version="1.4.4-preview.13" />
<dependency id="nanoFramework.System.Text" version="1.1.3-preview.13" />
<dependency id="nanoFramework.Runtime.Events" version="1.10.0-preview.6" />
<dependency id="nanoFramework.System.Collections" version="1.4.0-preview.14" />
<dependency id="nanoFramework.System.IO.FileSystem" version="1.0.3-preview.9" />
<dependency id="Bytewizer.NanoCLR.Core" version="2.1.8" />
<dependency id="Bytewizer.NanoCLR.DependencyInjection.Abstractions" version="2.1.8" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
<ItemGroup>
<Folder Include="Logging\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bytewizer.NanoCLR.Logging.Abstractions\Bytewizer.NanoCLR.Logging.Abstractions.nfproj" />
<ProjectReference Include="..\Bytewizer.NanoCLR.Logging\Bytewizer.NanoCLR.Logging.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
<ProjectExtensions>
<ProjectCapabilities>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
<ItemGroup>
<Folder Include="Logging\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bytewizer.NanoCLR.Logging.Abstractions\Bytewizer.NanoCLR.Logging.Abstractions.nfproj" />
<ProjectReference Include="..\Bytewizer.NanoCLR.Logging\Bytewizer.NanoCLR.Logging.nfproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.12.0-preview.5\lib\mscorlib.dll</HintPath>
Expand Down

0 comments on commit 2176663

Please sign in to comment.