Skip to content

Commit cef72de

Browse files
committed
Nearing release
1 parent c2cc41e commit cef72de

File tree

376 files changed

+16809
-11347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

376 files changed

+16809
-11347
lines changed

src/Server.7z

-72.8 MB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Data;
3+
using System.Reflection;
4+
using System.Security.Claims;
5+
using Microsoft.Extensions.DependencyInjection;
6+
7+
namespace Coderr.Server.Abstractions.Boot
8+
{
9+
public abstract class ConfigurationContext
10+
{
11+
12+
public Func<ClaimsPrincipal, IDbConnection> ConnectionFactory { get; set; }
13+
public IServiceCollection Services { get; set; }
14+
public Func<IServiceProvider> ServiceProvider { get; set; }
15+
public IConfiguration Configuration { get; set; }
16+
17+
public abstract void RegisterMessageTypes(Assembly assembly);
18+
}
19+
}

src/Server/Coderr.Server.ReportAnalyzer.Abstractions/ContainerServiceAttribute.cs renamed to src/Server/Coderr.Server.Abstractions/Boot/ContainerServiceAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Coderr.Server.ReportAnalyzer.Abstractions
3+
namespace Coderr.Server.Abstractions.Boot
44
{
55
public class ContainerServiceAttribute: Attribute
66
{

src/Server/Coderr.Server.Infrastructure/Boot/ISystemModule.cs renamed to src/Server/Coderr.Server.Abstractions/Boot/IAppModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
namespace Coderr.Server.Infrastructure.Boot
1+
namespace Coderr.Server.Abstractions.Boot
22
{
3-
public interface ISystemModule
3+
public interface IAppModule
44
{
55
void Configure(ConfigurationContext context);
66
void Start(StartContext context);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
3+
namespace Coderr.Server.Abstractions.Boot
4+
{
5+
public interface IConfiguration
6+
{
7+
IConfigurationSection GetSection(string name);
8+
string GetConnectionString(string name);
9+
IEnumerable<IConfigurationSection> GetChildren();
10+
}
11+
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
4+
namespace Coderr.Server.Abstractions.Boot
5+
{
6+
public interface IConfigurationSection
7+
{
8+
string this[string name] { get; }
9+
IEnumerable<IConfigurationSection> GetChildren();
10+
11+
string Value { get; }
12+
}
13+
14+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Linq;
3+
using System.Reflection;
4+
using Microsoft.Extensions.DependencyInjection;
5+
6+
namespace Coderr.Server.Abstractions.Boot
7+
{
8+
public static class RegisterExtensions
9+
{
10+
public static void RegisterContainerServices(this IServiceCollection serviceCollection, Assembly assembly)
11+
{
12+
var containerServices = assembly.GetTypes()
13+
.Where(x => x.GetCustomAttribute<ContainerServiceAttribute>(true) != null)
14+
.ToList();
15+
foreach (var containerService in containerServices)
16+
{
17+
var attr = containerService.GetCustomAttribute<ContainerServiceAttribute>();
18+
var interfaces = containerService.GetInterfaces();
19+
20+
// Hack so that the same instance is resolved for each interface
21+
if (interfaces.Length > 1)
22+
serviceCollection.RegisterService(attr, containerService, containerService);
23+
24+
foreach (var @interface in interfaces)
25+
{
26+
serviceCollection.RegisterService(attr, @interface, containerService);
27+
}
28+
29+
}
30+
}
31+
32+
private static void RegisterService(this IServiceCollection serviceCollection, ContainerServiceAttribute attr,
33+
Type service, Type implementation)
34+
{
35+
if (attr.IsSingleInstance)
36+
serviceCollection.AddSingleton(service, implementation);
37+
else if (attr.IsTransient)
38+
serviceCollection.AddTransient(service, implementation);
39+
else
40+
serviceCollection.AddScoped(service, implementation);
41+
}
42+
43+
public static void RegisterMessageHandlers(this IServiceCollection serviceCollection, Assembly assembly)
44+
{
45+
var types = assembly.GetTypes()
46+
.Where(y => y.GetInterfaces().Any(x => x.Name.Contains("IMessageHandler") || x.Name.Contains("IQueryHandler")))
47+
.ToList();
48+
foreach (var type in types)
49+
{
50+
serviceCollection.AddScoped(type, type);
51+
serviceCollection.AddScoped(type.GetInterfaces()[0], type);
52+
}
53+
}
54+
55+
}
56+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace Coderr.Server.Abstractions.Boot
4+
{
5+
public class StartContext
6+
{
7+
public IServiceProvider ServiceProvider { get; set; }
8+
}
9+
10+
}

src/Server/Coderr.Server.PluginApi/Coderr.Server.PluginApi.csproj renamed to src/Server/Coderr.Server.Abstractions/Coderr.Server.Abstractions.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\Coderr.Server.Api\Coderr.Server.Api.csproj" />
99
</ItemGroup>
1010

11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
13+
</ItemGroup>
14+
15+
1116
</Project>

src/Server/Coderr.Server.PluginApi/Config/ConfigurationStore.cs renamed to src/Server/Coderr.Server.Abstractions/Config/ConfigurationStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Coderr.Server.PluginApi.Config
3+
namespace Coderr.Server.Abstractions.Config
44
{
55
/// <summary>
66
/// Used to modify configuration settings.

0 commit comments

Comments
 (0)