Initial commit
This commit is contained in:
Коммит
22fae3b7cf
|
@ -0,0 +1,63 @@
|
|||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
|
@ -0,0 +1,369 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
#Sonarcloud
|
||||
.sonarqube
|
||||
|
||||
#VS Code
|
||||
.vscode
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) .NET Foundation and Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32519.379
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5CA8DDDF-50C5-4044-A78C-170228780423}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
version.json = version.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Hosting", "nanoFramework.Hosting\nanoFramework.Hosting.nfproj", "{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}"
|
||||
EndProject
|
||||
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.DependencyInjection", "..\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection.nfproj", "{A2B2222C-0553-4877-8CF1-4458B30C0081}"
|
||||
EndProject
|
||||
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Hosting", "samples\Hosting\Hosting.nfproj", "{E10613D2-3AEA-4D67-84D8-8560178C14B8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2B2222C-0553-4877-8CF1-4458B30C0081}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F36078E1-F784-459A-B4A7-330B3F2BBEA0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for implementing a long running <see cref="IHostedService"/>.
|
||||
/// </summary>
|
||||
public abstract class BackgroundService : IHostedService, IDisposable
|
||||
{
|
||||
private Thread _executeThread;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BackgroundService"/> class.
|
||||
/// </summary>
|
||||
protected BackgroundService()
|
||||
{
|
||||
ServiceName = GetType().Name;
|
||||
IsCancellationRequested = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether cancellation has been requested for this service.
|
||||
/// </summary>
|
||||
protected bool IsCancellationRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The service name to associate with the service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If not explicitly set, will default to the ServiceId property value.
|
||||
/// </remarks>
|
||||
public string ServiceName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Thread"/> that executes the background operation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Will return <see langword="null"/> if the background operation hasn't started.
|
||||
/// </remarks>
|
||||
public virtual Thread ExecuteThread() => _executeThread;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when the <see cref="IHostedService"/> starts. The implementation should return a task that represents
|
||||
/// the lifetime of the long running operation(s) being performed.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Thread"/> that represents the long running operations.</returns>
|
||||
protected abstract void ExecuteAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the application host is ready to start the service.
|
||||
/// </summary>
|
||||
public virtual Thread Start()
|
||||
{
|
||||
IsCancellationRequested = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Store the thread we're executing
|
||||
_executeThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ExecuteAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
});
|
||||
_executeThread.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return _executeThread;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the application host is performing a graceful shutdown.
|
||||
/// </summary>
|
||||
public virtual void Stop(int timeout = 10000)
|
||||
{
|
||||
if (_executeThread == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Request graceful termination.
|
||||
IsCancellationRequested = true;
|
||||
|
||||
if (_executeThread != null)
|
||||
{
|
||||
// Wait for thread to exit
|
||||
//_executeThread.Abort();
|
||||
_executeThread.Join(timeout);
|
||||
_executeThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides convenience methods for creating instances of <see cref="IHostBuilder"/> with pre-configured defaults.
|
||||
/// </summary>
|
||||
public static class Host
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HostBuilder"/> class with pre-configured defaults.
|
||||
/// </summary>
|
||||
/// <returns>The initialized <see cref="IHostBuilder"/>.</returns>
|
||||
public static IHostBuilder CreateDefaultBuilder()
|
||||
{
|
||||
var builder = new HostBuilder();
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using nanoFramework.Logging.Debug;
|
||||
using nanoFramework.DependencyInjection;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
public class HostBuilder : IHostBuilder
|
||||
{
|
||||
private bool _hostBuilt;
|
||||
private IServiceProvider _appServices;
|
||||
private HostBuilderContext _hostBuilderContext;
|
||||
private readonly ArrayList _configureServicesActions = new ArrayList();
|
||||
|
||||
/// <summary>
|
||||
/// A central location for sharing state between components during the host building process.
|
||||
/// </summary>
|
||||
public string[] Properties { get; } = new string[0];
|
||||
|
||||
/// <summary>
|
||||
/// Adds services to the container. This can be called multiple times and the results will be additive.
|
||||
/// </summary>
|
||||
/// <param name="configureDelegate">The delegate for configuring the <see cref="IConfigurationBuilder"/> that will be used
|
||||
/// to construct the <see cref="IConfiguration"/> for the host.</param>
|
||||
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
|
||||
public IHostBuilder ConfigureServices(ServiceContextDelegate configureDelegate)
|
||||
{
|
||||
_configureServicesActions.Add(configureDelegate ?? throw new ArgumentNullException(nameof(configureDelegate)));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the given actions to initialize the host. This can only be called once.
|
||||
/// </summary>
|
||||
/// <returns>An initialized <see cref="IHost"/></returns>
|
||||
public IHost Build()
|
||||
{
|
||||
if (_hostBuilt)
|
||||
{
|
||||
throw new InvalidOperationException("Build can only be called once");
|
||||
}
|
||||
_hostBuilt = true;
|
||||
|
||||
// Create host builder context
|
||||
_hostBuilderContext = new HostBuilderContext(Properties);
|
||||
|
||||
// Create service provider
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton(typeof(IHost), typeof(Internal.Host));
|
||||
services.AddSingleton(typeof(IHostBuilder), _hostBuilderContext);
|
||||
services.AddSingleton(typeof(ILoggerFactory), typeof(DebugLoggerFactory));
|
||||
|
||||
foreach (ServiceContextDelegate configureServicesAction in _configureServicesActions)
|
||||
{
|
||||
configureServicesAction(_hostBuilderContext, services);
|
||||
}
|
||||
|
||||
_appServices = services.BuildServiceProvider();
|
||||
if (_appServices == null)
|
||||
{
|
||||
throw new InvalidOperationException($"The BuildServiceProvider returned a null ServiceProvider.");
|
||||
}
|
||||
|
||||
return (Internal.Host)_appServices.GetRequiredService(typeof(IHost));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Context containing the common services on the <see cref="IHost" />. Some properties may be null until set by the <see cref="IHost" />.
|
||||
/// </summary>
|
||||
public class HostBuilderContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HostBuilderContext"/> class.
|
||||
/// </summary>
|
||||
public HostBuilderContext(string[] properties)
|
||||
{
|
||||
Properties = properties ?? throw new ArgumentNullException(nameof(properties));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A central location for sharing state between components during the host building process.
|
||||
/// </summary>
|
||||
public string[] Properties { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
namespace nanoFramework.Hosting
|
||||
{
|
||||
public static class HostingAbstractionsHostExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Starts the host synchronously.
|
||||
/// </summary>
|
||||
/// <param name="host">The <see cref="IHost"/> to start.</param>
|
||||
public static void Start(this IHost host)
|
||||
{
|
||||
host.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to gracefully stop the host with the given timeout.
|
||||
/// </summary>
|
||||
/// <param name="host">The <see cref="IHost"/> to stop.</param>
|
||||
public static void Stop(this IHost host)
|
||||
{
|
||||
host.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs an application and block the calling thread until host shutdown.
|
||||
/// </summary>
|
||||
/// <param name="host">The <see cref="IHost"/> to run.</param>
|
||||
public static void Run(this IHost host)
|
||||
{
|
||||
host.Start();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
public static class HostingHostBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds services to the container. This can be called multiple times and the results will be additive.
|
||||
/// </summary>
|
||||
/// <param name="hostBuilder">The <see cref="IHostBuilder" /> to configure.</param>
|
||||
/// <param name="configureDelegate">The delegate for configuring the <see cref="IServiceCollection"/>.</param>
|
||||
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
|
||||
public static IHostBuilder ConfigureServices(this IHostBuilder hostBuilder, ServiceAction configureDelegate)
|
||||
{
|
||||
return hostBuilder.ConfigureServices((context, collection) => configureDelegate(collection));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// A program abstraction.
|
||||
/// </summary>
|
||||
public interface IHost : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The programs configured services.
|
||||
/// </summary>
|
||||
IServiceProvider Services { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Start the program.
|
||||
/// </summary>
|
||||
void Start();
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to gracefully stop the program.
|
||||
/// </summary>
|
||||
void Stop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// A program initialization abstraction.
|
||||
/// </summary>
|
||||
public interface IHostBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// A central location for sharing state between components during the host building process.
|
||||
/// </summary>
|
||||
string[] Properties { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds services to the container. This can be called multiple times and the results will be additive.
|
||||
/// </summary>
|
||||
/// <param name="configureDelegate">The delegate for configuring the <see cref="IServiceCollection"/> that will be used
|
||||
/// to construct the <see cref="IServiceProvider"/>.</param>
|
||||
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
|
||||
IHostBuilder ConfigureServices(ServiceContextDelegate configureDelegate);
|
||||
|
||||
/// <summary>
|
||||
/// Run the given actions to initialize the host. This can only be called once.
|
||||
/// </summary>
|
||||
/// <returns>An initialized <see cref="IHost"/>.</returns>
|
||||
IHost Build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System.Threading;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines methods for objects that are managed by the host.
|
||||
/// </summary>
|
||||
public interface IHostedService
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggered when the application host is ready to start the service.
|
||||
/// </summary>
|
||||
Thread Start();
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the application host is performing a graceful shutdown.
|
||||
/// </summary>
|
||||
void Stop(int timeout = 1000);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using nanoFramework.DependencyInjection;
|
||||
using nanoFramework.Hosting.Hosting.Internal;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace nanoFramework.Hosting.Internal
|
||||
{
|
||||
internal class Host : IHost, IDisposable
|
||||
{
|
||||
private object[] _hostedServices;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public Host(IServiceProvider services, ILoggerFactory loggerFactory)
|
||||
{
|
||||
if (services == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(services));
|
||||
}
|
||||
|
||||
if (loggerFactory == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(loggerFactory));
|
||||
}
|
||||
|
||||
Services = services;
|
||||
_logger = loggerFactory.CreateLogger(nameof(Host));
|
||||
}
|
||||
|
||||
public IServiceProvider Services { get; }
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_logger.Starting();
|
||||
|
||||
_hostedServices = Services.GetServices(typeof(IHostedService));
|
||||
|
||||
ArrayList exceptions = new ArrayList();
|
||||
foreach (IHostedService hostedService in _hostedServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Thead exceptions are not passed back to main thread
|
||||
hostedService.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions.Count > 0)
|
||||
{
|
||||
var ex = new AggregateException("One or more hosted services failed to start.", exceptions);
|
||||
_logger.BackgroundServiceFaulted(ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
_logger.Started();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_logger.Stopping();
|
||||
|
||||
ArrayList exceptions = new ArrayList();
|
||||
foreach (IHostedService hostedService in _hostedServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
hostedService.Stop();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions.Count > 0)
|
||||
{
|
||||
var ex = new AggregateException("One or more hosted services failed to stop.", exceptions);
|
||||
_logger.StoppedWithException(ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
_logger.Stopped();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace nanoFramework.Hosting.Hosting.Internal
|
||||
{
|
||||
internal static class HostingLoggerExtensions
|
||||
{
|
||||
public static void ApplicationError(this ILogger logger, EventId eventId, string message, Exception exception)
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Critical,
|
||||
eventId: eventId,
|
||||
state: message,
|
||||
exception: exception,
|
||||
format: null);
|
||||
}
|
||||
|
||||
public static void Starting(this ILogger logger)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Debug,
|
||||
eventId: LoggerEventIds.Starting,
|
||||
state: "Hosting starting",
|
||||
exception: null,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Started(this ILogger logger)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Debug,
|
||||
eventId: LoggerEventIds.Started,
|
||||
state: "Hosting started",
|
||||
exception: null,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Stopping(this ILogger logger)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Debug,
|
||||
eventId: LoggerEventIds.Stopping,
|
||||
state: "Hosting stopping",
|
||||
exception: null,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Stopped(this ILogger logger)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Debug,
|
||||
eventId: LoggerEventIds.Stopped,
|
||||
state: "Hosting stopped",
|
||||
exception: null,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StoppedWithException(this ILogger logger, Exception ex)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Debug,
|
||||
eventId: LoggerEventIds.StoppedWithException,
|
||||
state: "Hosting shutdown exception",
|
||||
exception: ex,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void BackgroundServiceFaulted(this ILogger logger, Exception ex)
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Error))
|
||||
{
|
||||
logger.Log(
|
||||
logLevel: LogLevel.Error,
|
||||
eventId: LoggerEventIds.BackgroundServiceFaulted,
|
||||
state: "BackgroundService failed",
|
||||
exception: ex,
|
||||
format: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace nanoFramework.Hosting.Hosting.Internal
|
||||
{
|
||||
internal static class LoggerEventIds
|
||||
{
|
||||
public static readonly EventId Starting = new EventId(1, "Starting");
|
||||
public static readonly EventId Started = new EventId(2, "Started");
|
||||
public static readonly EventId Stopping = new EventId(3, "Stopping");
|
||||
public static readonly EventId Stopped = new EventId(4, "Stopped");
|
||||
public static readonly EventId StoppedWithException = new EventId(5, "StoppedWithException");
|
||||
public static readonly EventId ApplicationStartupException = new EventId(6, "ApplicationStartupException");
|
||||
public static readonly EventId ApplicationStoppingException = new EventId(7, "ApplicationStoppingException");
|
||||
public static readonly EventId ApplicationStoppedException = new EventId(8, "ApplicationStoppedException");
|
||||
public static readonly EventId BackgroundServiceFaulted = new EventId(9, "BackgroundServiceFaulted");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a function that can process a request.
|
||||
/// </summary>
|
||||
/// <param name="serviceCollection">Specifies the contract for a collection of service descriptors.</param>
|
||||
public delegate void ServiceAction(IServiceCollection serviceCollection);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
public static class ServiceCollectionHostedServiceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Add an <see cref="IHostedService"/> registration for the given type.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/> to register with.</param>
|
||||
/// <param name="implementationType">The implementation type of the service.</param>
|
||||
/// <returns>The original <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection AddHostedService(this IServiceCollection services, Type implementationType)
|
||||
{
|
||||
services.AddSingleton(typeof(IHostedService), implementationType);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a function that can process a request.
|
||||
/// </summary>
|
||||
/// <param name="context">The context for the request.</param>
|
||||
/// <param name="serviceCollection">Specifies the contract for a collection of service descriptors.</param>
|
||||
public delegate void ServiceContextDelegate(HostBuilderContext context, IServiceCollection serviceCollection);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace nanoFramework.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a function that can process a request.
|
||||
/// </summary>
|
||||
/// <param name="context">The context for the request.</param>
|
||||
/// <param name="serviceCollection">Specifies the contract for a collection of service descriptors.</param>
|
||||
public delegate void ServiceDelegate(HostBuilderContext context, IServiceCollection serviceCollection);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
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("Hosting")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Hosting")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[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")]
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// This attribute is mandatory when building Interop libraries //
|
||||
// update this whenever the native assembly signature changes //
|
||||
[assembly: AssemblyNativeVersion("1.0.0.0")]
|
||||
/////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,59 @@
|
|||
<?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>{AEEA2C38-FF56-4ACD-9DF5-E0BEA2D1263A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<RootNamespace>nanoFramework.Hosting</RootNamespace>
|
||||
<AssemblyName>nanoFramework.Hosting</AssemblyName>
|
||||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
|
||||
<ItemGroup>
|
||||
<Compile Include="Hosting\BackgroundService.cs" />
|
||||
<Compile Include="Hosting\Host.cs" />
|
||||
<Compile Include="Hosting\HostBuilder.cs" />
|
||||
<Compile Include="Hosting\HostBuilderContext.cs" />
|
||||
<Compile Include="Hosting\HostingAbstractionsHostExtensions.cs" />
|
||||
<Compile Include="Hosting\HostingHostBuilderExtensions.cs" />
|
||||
<Compile Include="Hosting\Internal\HostingLoggerExtensions.cs" />
|
||||
<Compile Include="Hosting\IHost.cs" />
|
||||
<Compile Include="Hosting\IHostBuilder.cs" />
|
||||
<Compile Include="Hosting\IHostedService.cs" />
|
||||
<Compile Include="Hosting\Internal\Host.cs" />
|
||||
<Compile Include="Hosting\ServiceCollectionHostedServiceExtensions.cs" />
|
||||
<Compile Include="Hosting\ServiceAction.cs" />
|
||||
<Compile Include="Hosting\ServiceContextDelegate.cs" />
|
||||
<Compile Include="Hosting\Internal\LoggerEventIds.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Hosting\ServiceDelegate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>..\packages\nanoFramework.CoreLibrary.1.12.0\lib\mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nanoFramework.Logging">
|
||||
<HintPath>..\packages\nanoFramework.Logging.1.0.1.29\lib\nanoFramework.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection.nfproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
|
||||
<ProjectExtensions>
|
||||
<ProjectCapabilities>
|
||||
<ProjectConfigurationsDeclaredAsItems />
|
||||
</ProjectCapabilities>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="nanoFramework.CoreLibrary" version="1.12.0" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.Logging" version="1.0.1.29" targetFramework="netnano1.0" />
|
||||
</packages>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>nanoframework.DependencyInjection</id>
|
||||
<version>$version$</version>
|
||||
<title>nanoframework.DependencyInjection</title>
|
||||
<authors>nanoframework</authors>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="file">LICENSE.md</license>
|
||||
<releaseNotes>
|
||||
</releaseNotes>
|
||||
<readme>docs\README.md</readme>
|
||||
<developmentDependency>false</developmentDependency>
|
||||
<projectUrl>https://github.com/nanoframework/nanoframework.DependencyInjection</projectUrl>
|
||||
<icon>images\nf-logo.png</icon>
|
||||
<repository type="git" url="https://github.com/nanoframework/nanoframework.DependencyInjection" commit="$commit$" />
|
||||
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
|
||||
<description>This package includes the nanoframework.DependencyInjection assembly for .NET nanoFramework C# projects.</description>
|
||||
<tags>nanoFramework C# csharp netmf netnf dependencyinjection</tags>
|
||||
<dependencies>
|
||||
<dependency id="nanoFramework.CoreLibrary" version="1.12.0" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="WebSockets.Server\bin\Release\nanoframework.DependencyInjection.dll" target="lib\nanoframework.DependencyInjection.dll" />
|
||||
<file src="WebSockets.Server\bin\Release\nanoframework.DependencyInjection.pdb" target="lib\nanoframework.DependencyInjection.pdb" />
|
||||
<file src="WebSockets.Server\bin\Release\nanoframework.DependencyInjection.pdbx" target="lib\nanoframework.DependencyInjection.pdbx" />
|
||||
<file src="WebSockets.Server\bin\Release\nanoframework.DependencyInjection.pe" target="lib\nanoframework.DependencyInjection.pe" />
|
||||
<file src="WebSockets.Server\bin\Release\nanoframework.DependencyInjection.xml" target="lib\nanoframework.DependencyInjection.xml" />
|
||||
<file src="assets\readme.txt" target="" />
|
||||
<file src="README.md" target="docs\" />
|
||||
<file src="assets\nf-logo.png" target="images\" />
|
||||
<file src="LICENSE.md" target="" />
|
||||
</files>
|
||||
</package>
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32519.379
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Hostring", "Hosting\Hosting.nfproj", "{E10613D2-3AEA-4D67-84D8-8560178C14B8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E10613D2-3AEA-4D67-84D8-8560178C14B8}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1EC40AA7-C769-4EBB-9C18-8CE1692239EB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Device.Gpio;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
internal class HardwareService : IHardwareService, IDisposable
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly GpioController _gpioController;
|
||||
|
||||
public HardwareService(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_gpioController = new GpioController();
|
||||
_logger = loggerFactory.CreateLogger(nameof(HardwareService));
|
||||
}
|
||||
|
||||
public GpioController GpioController { get { return _gpioController; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_gpioController.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?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>e10613d2-3aea-4d67-84d8-8560178c14b8</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<RootNamespace>DependencyInjection</RootNamespace>
|
||||
<AssemblyName>DependencyInjection</AssemblyName>
|
||||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
|
||||
<ItemGroup>
|
||||
<Compile Include="HardwareService.cs" />
|
||||
<Compile Include="IHardwareService.cs" />
|
||||
<Compile Include="Led3HostedService.cs" />
|
||||
<Compile Include="Led2HostedService.cs" />
|
||||
<Compile Include="Led1HostedService.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>..\packages\nanoFramework.CoreLibrary.1.12.0\lib\mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nanoFramework.Logging">
|
||||
<HintPath>..\..\packages\nanoFramework.Logging.1.0.1.29\lib\nanoFramework.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nanoFramework.Runtime.Events">
|
||||
<HintPath>..\..\packages\nanoFramework.Runtime.Events.1.10.0\lib\nanoFramework.Runtime.Events.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Device.Gpio">
|
||||
<HintPath>..\..\packages\nanoFramework.System.Device.Gpio.1.0.4\lib\System.Device.Gpio.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection\nanoFramework.DependencyInjection.nfproj" />
|
||||
<ProjectReference Include="..\..\nanoFramework.Hosting\nanoFramework.Hosting.nfproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
|
||||
<ProjectExtensions>
|
||||
<ProjectCapabilities>
|
||||
<ProjectConfigurationsDeclaredAsItems />
|
||||
</ProjectCapabilities>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
|
@ -0,0 +1,9 @@
|
|||
using System.Device.Gpio;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
public interface IHardwareService
|
||||
{
|
||||
GpioController GpioController { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Device.Gpio;
|
||||
using System.Threading;
|
||||
|
||||
using nanoFramework.Hosting;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
internal class Led1HostedService : BackgroundService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHardwareService _hardware;
|
||||
|
||||
public Led1HostedService(ILoggerFactory loggerFactory, IHardwareService hardware)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(Led1HostedService));
|
||||
_hardware = hardware;
|
||||
}
|
||||
|
||||
protected override void ExecuteAsync()
|
||||
{
|
||||
var ledPin = 16; //LD1;
|
||||
|
||||
GpioPin led = _hardware.GpioController.OpenPin(ledPin, PinMode.Output);
|
||||
led.Write(PinValue.Low);
|
||||
|
||||
_logger.LogInformation($"Started blinking led 1 on pin {ledPin}.");
|
||||
|
||||
while (true)
|
||||
{
|
||||
led.Write(PinValue.High);
|
||||
_logger.LogInformation("Led 1 status: on");
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
led.Write(PinValue.Low);
|
||||
_logger.LogInformation("Led 1 status: off");
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Device.Gpio;
|
||||
using System.Threading;
|
||||
|
||||
using nanoFramework.Hosting;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
internal class Led2HostedService : BackgroundService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHardwareService _hardware;
|
||||
|
||||
public Led2HostedService(ILoggerFactory loggerFactory, IHardwareService hardware)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(Led2HostedService));
|
||||
_hardware = hardware;
|
||||
}
|
||||
|
||||
protected override void ExecuteAsync()
|
||||
{
|
||||
var ledPin = 23; // LD2 30=LD3
|
||||
|
||||
GpioPin led = _hardware.GpioController.OpenPin(ledPin, PinMode.Output);
|
||||
led.Write(PinValue.Low);
|
||||
|
||||
_logger.LogInformation($"Started blinking led 2 on pin {ledPin}.");
|
||||
|
||||
while (true)
|
||||
{
|
||||
led.Write(PinValue.High);
|
||||
_logger.LogInformation("Led 2 status: on");
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
led.Write(PinValue.Low);
|
||||
_logger.LogInformation("Led 2 status: off");
|
||||
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Device.Gpio;
|
||||
using System.Threading;
|
||||
|
||||
using nanoFramework.Hosting;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
internal class Led3HostedService : BackgroundService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHardwareService _hardware;
|
||||
|
||||
public Led3HostedService(ILoggerFactory loggerFactory, IHardwareService hardware)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(Led3HostedService));
|
||||
_hardware = hardware;
|
||||
}
|
||||
|
||||
protected override void ExecuteAsync()
|
||||
{
|
||||
var ledPin = 30; //LD3;
|
||||
|
||||
GpioPin led = _hardware.GpioController.OpenPin(ledPin, PinMode.Output);
|
||||
led.Write(PinValue.Low);
|
||||
|
||||
_logger.LogInformation($"Started blinking led 3 on pin {ledPin}.");
|
||||
|
||||
while (true)
|
||||
{
|
||||
led.Write(PinValue.High);
|
||||
_logger.LogInformation("Led 3 status: on");
|
||||
|
||||
Thread.Sleep(300);
|
||||
|
||||
led.Write(PinValue.Low);
|
||||
_logger.LogInformation("Led 3 status: off");
|
||||
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using nanoFramework.Hosting;
|
||||
using nanoFramework.DependencyInjection;
|
||||
|
||||
namespace Hosting
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var hostBuilder = Host.CreateDefaultBuilder()
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddSingleton(typeof(IHardwareService), typeof(HardwareService));
|
||||
services.AddHostedService(typeof(Led1HostedService));
|
||||
services.AddHostedService(typeof(Led2HostedService));
|
||||
services.AddHostedService(typeof(Led3HostedService));
|
||||
}).Build();
|
||||
|
||||
hostBuilder.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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("Hosting")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Hosting")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[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")]
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="nanoFramework.CoreLibrary" version="1.12.0" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.Logging" version="1.0.1.29" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.Runtime.Events" version="1.10.0" targetFramework="netnano1.0" />
|
||||
<package id="nanoFramework.System.Device.Gpio" version="1.0.4" targetFramework="netnano1.0" />
|
||||
</packages>
|
|
@ -0,0 +1,74 @@
|
|||
<UserSettings>
|
||||
<ApplicationIdentity version="12.0"/>
|
||||
<ToolsOptions>
|
||||
<ToolsOptionsCategory name="TextEditor" RegisteredName="TextEditor">
|
||||
<ToolsOptionsSubCategory name="AllLanguages" RegisteredName="AllLanguages" PackageName="Text Management Package"/>
|
||||
<ToolsOptionsSubCategory name="CSharp" RegisteredName="CSharp" PackageName="Text Management Package">
|
||||
<PropertyValue name="TabSize">4</PropertyValue>
|
||||
<PropertyValue name="InsertTabs">false</PropertyValue>
|
||||
<PropertyValue name="IndentSize">4</PropertyValue>
|
||||
<PropertyValue name="BraceCompletion">true</PropertyValue>
|
||||
</ToolsOptionsSubCategory>
|
||||
<ToolsOptionsSubCategory name="CSharp-Specific" RegisteredName="CSharp-Specific" PackageName="Visual C# Language Service Package">
|
||||
<PropertyValue name="NewLines_QueryExpression_EachClause">1</PropertyValue>
|
||||
<PropertyValue name="Space_Normalize">0</PropertyValue>
|
||||
<PropertyValue name="Space_AroundBinaryOperator">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnPaste">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_Method">1</PropertyValue>
|
||||
<PropertyValue name="Indent_CaseLabels">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnBlockCompletion">1</PropertyValue>
|
||||
<PropertyValue name="CodeDefinitionWindow_DocumentationComment_IndentOffset">2</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_ControlFlow">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_AnonymousMethod">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinOtherParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Wrapping_KeepStatementsOnSingleLine">1</PropertyValue>
|
||||
<PropertyValue name="Space_AfterBasesColon">1</PropertyValue>
|
||||
<PropertyValue name="Indent_Braces">0</PropertyValue>
|
||||
<PropertyValue name="Wrapping_IgnoreSpacesAroundVariableDeclaration">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinMethodCallParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_AfterCast">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_CollectionInitializer">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_AnonymousTypeInitializer_EachMember">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Keywords_Catch">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_ObjectInitializer">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_ArrayInitializer">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinExpressionParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_InControlFlowConstruct">1</PropertyValue>
|
||||
<PropertyValue name="Formatting_TriggerOnStatementCompletion">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_Keywords_Finally">1</PropertyValue>
|
||||
<PropertyValue name="Space_BetweenEmptyMethodDeclarationParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Indent_UnindentLabels">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_ObjectInitializer_EachMember">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Keywords_Else">1</PropertyValue>
|
||||
<PropertyValue name="Space_WithinMethodDeclarationParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_BetweenEmptyMethodCallParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeSemicolonsInForStatement">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeComma">0</PropertyValue>
|
||||
<PropertyValue name="Space_AfterMethodCallName">0</PropertyValue>
|
||||
<PropertyValue name="Space_AfterComma">1</PropertyValue>
|
||||
<PropertyValue name="Wrapping_IgnoreSpacesAroundBinaryOperators">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeBasesColon">1</PropertyValue>
|
||||
<PropertyValue name="Space_AfterMethodDeclarationName">0</PropertyValue>
|
||||
<PropertyValue name="Space_AfterDot">0</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_Type">1</PropertyValue>
|
||||
<PropertyValue name="Space_AfterLambdaArrow">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_LambdaExpressionBody">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinSquares">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeLambdaArrow">1</PropertyValue>
|
||||
<PropertyValue name="NewLines_Braces_AnonymousTypeInitializer">0</PropertyValue>
|
||||
<PropertyValue name="Space_WithinCastParentheses">0</PropertyValue>
|
||||
<PropertyValue name="Space_AfterSemicolonsInForStatement">1</PropertyValue>
|
||||
<PropertyValue name="Indent_CaseContents">0</PropertyValue>
|
||||
<PropertyValue name="Indent_FlushLabelsLeft">1</PropertyValue>
|
||||
<PropertyValue name="Wrapping_PreserveSingleLine">1</PropertyValue>
|
||||
<PropertyValue name="Space_BetweenEmptySquares">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeOpenSquare">0</PropertyValue>
|
||||
<PropertyValue name="Space_BeforeDot">0</PropertyValue>
|
||||
<PropertyValue name="Indent_BlockContents">1</PropertyValue>
|
||||
<PropertyValue name="SortUsings_PlaceSystemFirst">1</PropertyValue>
|
||||
<PropertyValue name="SortUsings">1</PropertyValue>
|
||||
<PropertyValue name="RemoveUnusedUsings">1</PropertyValue>
|
||||
</ToolsOptionsSubCategory>
|
||||
</ToolsOptionsCategory>
|
||||
</ToolsOptions>
|
||||
</UserSettings>
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "1.0.0",
|
||||
"assemblyVersion": {
|
||||
"precision": "revision"
|
||||
},
|
||||
"semVer1NumericIdentifierPadding": 3,
|
||||
"nuGetPackageVersion": {
|
||||
"semVer": 1.0,
|
||||
"precision": "revision"
|
||||
},
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/main$",
|
||||
"^refs/heads/v\\d+(?:\\.\\d+)?$"
|
||||
],
|
||||
"cloudBuild": {
|
||||
"setAllVariables": true
|
||||
},
|
||||
"release": {
|
||||
"branchName": "release-v{version}",
|
||||
"versionIncrement": "build",
|
||||
"firstUnstableTag": "preview"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче