This commit is contained in:
2020-10-07 00:07:52 +02:00
parent b3ceb5e1aa
commit 92a88efa65
4 changed files with 19 additions and 11 deletions
@@ -13,13 +13,13 @@ namespace zero.Core.Extensions
/// <summary>
/// Adds all found implementations based on the service type and assembly discovery rules
/// </summary>
public static void AddAll<TService>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient) => services.AddAll(typeof(TService), lifetime);
public static void AddAll<TService>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient, bool asSelf = false) => services.AddAll(typeof(TService), lifetime, asSelf);
/// <summary>
/// Adds all found implementations based on the service type and assembly discovery rules
/// </summary>
public static void AddAll(this IServiceCollection services, Type serviceType, ServiceLifetime lifetime = ServiceLifetime.Transient)
public static void AddAll(this IServiceCollection services, Type serviceType, ServiceLifetime lifetime = ServiceLifetime.Transient, bool asSelf = false)
{
if (AssemblyDiscovery.Current == null)
{
@@ -42,7 +42,7 @@ namespace zero.Core.Extensions
foreach ((Type, Type) match in matches)
{
services.Add(new ServiceDescriptor(match.Item1, match.Item2, lifetime));
services.Add(new ServiceDescriptor(asSelf ? match.Item2 : match.Item1, match.Item2, lifetime));
}
}
// add implementations with specific service types
@@ -50,7 +50,7 @@ namespace zero.Core.Extensions
{
foreach (Type type in AssemblyDiscovery.Current.GetTypes(serviceType))
{
services.Add(new ServiceDescriptor(serviceType, type, lifetime));
services.Add(new ServiceDescriptor(asSelf ? type : serviceType, type, lifetime));
}
}
}
+6 -2
View File
@@ -4,8 +4,10 @@ using System.Collections.Generic;
using zero.Commerce.Options;
using zero.Core.Options;
using zero.Core.Plugins;
using zero.Core.Extensions;
using zero.Debug.Sync;
using zero.Debug.TestData;
using zero.Core.Messages;
namespace zero.TestData
{
@@ -52,8 +54,10 @@ namespace zero.TestData
opts.ChannelFeatures.Add("channel.altFrontend", "Alternative header", "Render a simplified header in the frontend");
});
services.AddTransient<CountryBlueprintHandler>(); // TODO auto-register handlers
services.AddTransient<PropertyBlueprintHandler>();
services.AddAll(typeof(IMessageHandler<>), ServiceLifetime.Transient, true);
//services.AddTransient<CountryBlueprintHandler>(); // TODO auto-register handlers
//services.AddTransient<PropertyBlueprintHandler>();
services.AddTransient<ITestService, TestService>();
}
}
+7 -4
View File
@@ -11,13 +11,14 @@
<slot name="info-boxes"></slot>
<div class="ui-box" v-if="isShared" :class="{'is-active': value.isActive }">
<div class="editor-global-flag">
<i class="fth-git-pull-request"></i>
<i class="fth-rotate-cw"></i>
<p>
<b>This entity is bound to a parent</b> and automatically synchronised.<br>
<!--<a href="/">Edit parent</a>-->
</p>
</div>
<ui-button type="light" label="Edit parent" @click="editBlueprint(value.blueprint)" />
<ui-button type="light small" label="Edit parent" @click="editBlueprint(value.blueprint)" />
<ui-button type="light small" label="Settings" @click="editBlueprint(value.blueprint)" />
</div>
<div class="ui-box editor-active-toggle" v-if="activeToggle" :class="{'is-active': value.isActive }">
<slot name="settings">
@@ -353,7 +354,8 @@
{
display: grid;
grid-template-columns: auto minmax(0, 1fr);
grid-gap: 20px;
grid-gap: 16px;
padding-bottom: 10px;
align-items: center;
font-size: var(--font-size);
line-height: 1.5;
@@ -366,8 +368,9 @@
i
{
font-size: 32px;
font-size: 28px;
color: var(--color-text);
margin-top: -2px;
}
& + .ui-button
+2 -1
View File
@@ -71,7 +71,8 @@ button::-moz-focus-inner
&.type-small
{
height: 32px;
height: 34px;
font-size: var(--font-size-s);
padding: 0 12px;
}