Skip to content

Commit

Permalink
Add AppTemplate application
Browse files Browse the repository at this point in the history
  • Loading branch information
DrLeh committed Apr 17, 2019
1 parent fd75df5 commit 0528b3d
Show file tree
Hide file tree
Showing 82 changed files with 25,045 additions and 0 deletions.
129 changes: 129 additions & 0 deletions AppTemplate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/*
[Oo]bj/
PrecompiledWeb/
.vs/

# mstest test results
TestResults
[Tt]est[Rr]esult
[Bb]uild[Ll]og.*

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug*/
[Rr]elease/
x64/
combined_*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
*.vssscc
.builds
*.nupkg

*.pidb

*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
src/ESP.Web/BuildConfig/*/Release_Web.config
src/ESP.Web.Public/BuildConfig/*/Release_Web.config
src/ESP.Web.Api/Content/XmlDocument.xml
buildinfo.txt

# Visual Studio profiler
*.psess
*.vsp

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*

# NCrunch
*.ncrunch*
.*crunch*.local.xml
nCrunchTemp_*

# 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

# Others
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# 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

# NuGet
packages/

.build/ASI.Barista.Plugins.ESP.Control/
.build/ASI.Barista.Plugins.ESP.Import/
.build/ASI.Barista.Plugins.ESP.Notifications/
.build/ASI.Barista.Plugins.ESP.Users/
.build/ASI.Barista.Plugins.ESP.Events/
.build/ASI.Barista.Plugins.ESP.CrmRpc/
.build/ASI.Barista.Plugins.ESP.Export/


# npm
node_modules
npm-debug.js

bower_components
reports/
_NCrunch_ESP/StoredText/*
54 changes: 54 additions & 0 deletions AppTemplate/MyApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.329
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp.Core", "src\MyApp.Core\MyApp.Core.csproj", "{579DE70C-9978-46D9-9A54-F129049B464A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp.Data", "src\MyApp.Data\MyApp.Data.csproj", "{A0A46E15-FD80-4E64-91E5-45F1BD6A56B6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{335041E2-0F31-4751-88FD-5879C386A042}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp.Core.Test", "src\MyApp.Core.Test\MyApp.Core.Test.csproj", "{9B9C0F65-B873-4550-98AD-1718D2EABCF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp.Web", "src\MyApp.Web\MyApp.Web.csproj", "{94AF02F5-C8F6-4055-8993-4858170F0CD1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp.Console", "src\MyApp.Console\MyApp.Console.csproj", "{1CD5B9FA-EA1E-4597-A681-2B9F4FB983A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{579DE70C-9978-46D9-9A54-F129049B464A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{579DE70C-9978-46D9-9A54-F129049B464A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{579DE70C-9978-46D9-9A54-F129049B464A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{579DE70C-9978-46D9-9A54-F129049B464A}.Release|Any CPU.Build.0 = Release|Any CPU
{A0A46E15-FD80-4E64-91E5-45F1BD6A56B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0A46E15-FD80-4E64-91E5-45F1BD6A56B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0A46E15-FD80-4E64-91E5-45F1BD6A56B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0A46E15-FD80-4E64-91E5-45F1BD6A56B6}.Release|Any CPU.Build.0 = Release|Any CPU
{9B9C0F65-B873-4550-98AD-1718D2EABCF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B9C0F65-B873-4550-98AD-1718D2EABCF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B9C0F65-B873-4550-98AD-1718D2EABCF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B9C0F65-B873-4550-98AD-1718D2EABCF1}.Release|Any CPU.Build.0 = Release|Any CPU
{94AF02F5-C8F6-4055-8993-4858170F0CD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94AF02F5-C8F6-4055-8993-4858170F0CD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94AF02F5-C8F6-4055-8993-4858170F0CD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94AF02F5-C8F6-4055-8993-4858170F0CD1}.Release|Any CPU.Build.0 = Release|Any CPU
{1CD5B9FA-EA1E-4597-A681-2B9F4FB983A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CD5B9FA-EA1E-4597-A681-2B9F4FB983A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CD5B9FA-EA1E-4597-A681-2B9F4FB983A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CD5B9FA-EA1E-4597-A681-2B9F4FB983A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9B9C0F65-B873-4550-98AD-1718D2EABCF1} = {335041E2-0F31-4751-88FD-5879C386A042}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B06A0E14-8774-4918-A828-257B61224E9A}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions AppTemplate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Sample ASP.Net app with basic setup with proper infrastructure
36 changes: 36 additions & 0 deletions AppTemplate/src/MyApp.Console/MyApp.Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MyApp.Core\MyApp.Core.csproj" />
<ProjectReference Include="..\MyApp.Data\MyApp.Data.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Extensions.DependencyInjection">
<HintPath>..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.dependencyinjection\2.1.1\lib\netcoreapp2.0\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions">
<HintPath>..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.dependencyinjection.abstractions\2.1.1\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
56 changes: 56 additions & 0 deletions AppTemplate/src/MyApp.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MyApp.Core.Configuration;
using MyApp.Core.Models;
using System;

namespace MyApp.Console
{
public class Program
{
private static IServiceProvider container;

static void Startup()
{
var services = new ServiceCollection();
new Registry().RegisterServices(services);
container = services
.AddLogging()
.BuildServiceProvider();

//configure console logging
container
.GetService<ILoggerFactory>()
.AddConsole(LogLevel.Debug);

var logger = container.GetService<ILoggerFactory>()
.CreateLogger<Program>();
logger.LogDebug("Starting application");
}

static void Main(string[] args)
{
Startup();


//you can build this out to be an interactive console app to run,
// or just comment out what code you don't want to run
// but if you're trying to get something figured out, it's a lot easier to
// just run this console app with everything configured how you expect it
// than it is to fire up the web app, click through, enter fields, etc.
ConfigurationTest();
//DoSomethingElse();


System.Console.WriteLine("Done! Press enter to exit");
System.Console.ReadLine();
}

public static void ConfigurationTest()
{
var config = container.GetService<IConfiguration>();
System.Console.WriteLine($"MySetting: {config.MySetting}");
System.Console.WriteLine($"Db Setting: {config.Db.ConnectionString}");
}
}
}
22 changes: 22 additions & 0 deletions AppTemplate/src/MyApp.Console/Startup/Registry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.DependencyInjection;
using MyApp.Core.Data;
using MyApp.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyApp.Console
{
public class Registry
{
public void RegisterServices(IServiceCollection services)
{
//by abstracting these into a Registry, if you have a second app you want to run with
// the same codebase, you can just call these registries. Some of them might have
// access to different things so this list could vary by app.
new MyApp.Core.Startup.Registry().RegisterServices(services);
new MyApp.Data.Startup.Registry().RegisterServices(services);
}
}
}
6 changes: 6 additions & 0 deletions AppTemplate/src/MyApp.Console/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"MySetting": "Console Setting",
"Db": {
"ConnectionString" : "MyConnStr"
}
}
22 changes: 22 additions & 0 deletions AppTemplate/src/MyApp.Core.Test/MyApp.Core.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MyApp.Core\MyApp.Core.csproj" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions AppTemplate/src/MyApp.Core.Test/Startup/RegistryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using MyApp.Core.Configuration;
using MyApp.Core.Startup;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;

namespace MyApp.Core.Test.Startup
{
//Even registrations can be unit tested, nothing is safe!
[TestFixture]
public class RegistryTest
{
[Test]
public void Register_Test()
{
var services = new ServiceCollection();

//act
new Registry().RegisterServices(services);

var container = services.BuildServiceProvider();
}
}
}
Loading

0 comments on commit 0528b3d

Please sign in to comment.