break widget related stuff into its own project as the main HB project was just becoming too bloated
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,65 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWidget(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IInitializer, WidgetInitializer>();
|
||||
services.AddTransient<IFactory<Type, IWidget>, WidgetFactory>();
|
||||
|
||||
services.AddHandler<WidgetEnumeratorHandler>();
|
||||
services.AddHandler<WidgetAssemblyHandler>();
|
||||
services.AddHandler<WidgetHandler>();
|
||||
services.AddHandler<WidgetHostHandler>();
|
||||
|
||||
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>, WidgetContainerFactory>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent>(this IServiceCollection services)
|
||||
where TWidgetContent :
|
||||
IWidgetViewModel
|
||||
{
|
||||
Type contentType = typeof(TWidgetContent);
|
||||
Type templateType = typeof(IWidgetView);
|
||||
|
||||
string key = contentType.Name;
|
||||
|
||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||
services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!);
|
||||
|
||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||
services.TryAddKeyedTransient(key, (provider, key) => provider.GetService<IWidgetView>()!);
|
||||
|
||||
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent,
|
||||
TWidgetTemplate>(this IServiceCollection services)
|
||||
where TWidgetContent :
|
||||
IWidgetViewModel
|
||||
{
|
||||
Type contentType = typeof(TWidgetContent);
|
||||
Type templateType = typeof(TWidgetTemplate);
|
||||
|
||||
string key = contentType.Name;
|
||||
|
||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||
services.TryAddTransient(templateType);
|
||||
|
||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||
services.TryAddKeyedTransient(templateType, key);
|
||||
|
||||
services.AddTransient<IContentTemplateDescriptor>(provider =>
|
||||
new ContentTemplateDescriptor { ContentType = contentType,
|
||||
TemplateType = templateType, Key = key });
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidget
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidgetBuilder
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public static class IWidgetBuilderExtensions
|
||||
{
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidgetComponentViewModel : IDisposable;
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidgetHost :
|
||||
IInitializer
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidgetView;
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public interface IWidgetViewModel : IDisposable;
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public record Started<TValue>(TValue Value) : INotification;
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public record Stopped<TValue>(TValue Value) : INotification;
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public record WidgetAssembly(Assembly? Assembly = default) :
|
||||
INotification;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetAssemblyHandler(IMediator mediator,
|
||||
IFactory<Type, IWidget> factory) :
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public record WidgetAvailability
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(WidgetBarViewModel))]
|
||||
public partial class WidgetBarViewModel(ITemplateFactory templateFactory,
|
||||
@@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetBuilder<TConfiguration>(TConfiguration configuration) :
|
||||
IWidgetBuilder<TConfiguration>
|
||||
@@ -1,7 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(Id))]
|
||||
public partial class WidgetButtonViewModel(IServiceFactory serviceFactory,
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public partial class WidgetComponentViewModel :
|
||||
ObservableCollectionViewModel<IWidgetComponentViewModel>,
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
public class WidgetConfiguration
|
||||
{
|
||||
public string? Description { get; set; }
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public record WidgetConfigurationChanged<TConfiguration> : INotification;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetConfigurationHandler(IValue<WidgetAvailability> widgetAvailability) :
|
||||
INotificationHandler<ConfigurationChanged<WidgetConfiguration>>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetContainerFactory(IServiceFactory factory) :
|
||||
IFactory<IWidgetHost, WidgetContainerViewModel?>
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public partial class WidgetContainerViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetEnumerationHandler(IHostEnvironment hostEnvironment,
|
||||
public class WidgetEnumeratorHandler(IHostEnvironment hostEnvironment,
|
||||
IMediator mediator) :
|
||||
INotificationHandler<Enumerate<IWidget>>
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetFactory :
|
||||
IFactory<Type, IWidget>
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetHandler(IProxyServiceCollection<IWidgetBuilder> typedServices,
|
||||
IServiceProvider provider,
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetHost :
|
||||
INotificationHandler<Changed<WidgetAvailability>>,
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetHostHandler(IMediator mediator,
|
||||
IFactory<IWidgetHost, WidgetContainerViewModel?> factory) :
|
||||
@@ -12,8 +12,8 @@ public class WidgetHostHandler(IMediator mediator,
|
||||
{
|
||||
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
|
||||
{
|
||||
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel), nameof(WidgetBarViewModel),
|
||||
cancellationToken);
|
||||
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel),
|
||||
nameof(WidgetBarViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetInitializer(IMediator mediator) :
|
||||
IInitializer
|
||||
@@ -1,7 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(Id))]
|
||||
public partial class WidgetMenuViewModel(IServiceFactory serviceFactory,
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetMonitor :
|
||||
IInitializer
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public sealed class WidgetService(IEnumerable<IInitializer> initializers) :
|
||||
IHostedService
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Hyperbar;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(Id))]
|
||||
public partial class WidgetSplitButtonViewModel(IServiceFactory serviceFactory,
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public class WidgetViewModelEnumerator :
|
||||
INotificationHandler<Enumerate<IWidgetViewModel>>
|
||||
{
|
||||
public Task Handle(Enumerate<IWidgetViewModel> notification,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Windows.Media.Control;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
public class MediaControllerWidgetConfiguration :
|
||||
WidgetConfiguration
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Hyperbar.Widget;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
public class MediaControllerWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Hyperbar.Widget;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
public class PrimaryWidgetConfiguration : WidgetConfiguration
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfiguration :
|
||||
WidgetConfiguration
|
||||
{
|
||||
public List<PrimaryCommandConfiguration> Commands { get; set; } = [];
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
||||
PrimaryWidgetConfiguration configuration,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
[NotificationHandler(nameof(PrimaryWidgetViewModel))]
|
||||
public class PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentEnumerationHandler(PrimaryWidgetConfiguration configuration,
|
||||
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Widget;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class WidgetComponentProvider(ICache<Guid, IWidgetComponentViewModel> cache) :
|
||||
IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Widget;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Windows.Interop;
|
||||
using Hyperbar.Windows.UI;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Widget;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
+19
-1
@@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.UI", "Hype
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Interop", "Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj", "{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Windows.MediaController", "Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj", "{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.MediaController", "Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj", "{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Widget", "Hyperbar.Widget\Hyperbar.Widget.csproj", "{D38F95E6-744B-45DB-AF67-F331FB73615A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -167,6 +169,22 @@ Global
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x64.Build.0 = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.Build.0 = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -149,18 +149,9 @@ public static class IServiceCollectionExtensions
|
||||
|
||||
services.AddSingleton<IDisposer, Disposer>();
|
||||
|
||||
services.AddTransient<IInitializer, WidgetInitializer>();
|
||||
services.AddTransient<IFactory<Type, IWidget>, WidgetFactory>();
|
||||
|
||||
services.AddHandler<WidgetEnumerationHandler>();
|
||||
services.AddHandler<WidgetAssemblyHandler>();
|
||||
services.AddHandler<WidgetHandler>();
|
||||
services.AddHandler<WidgetHostHandler>();
|
||||
|
||||
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>, WidgetContainerFactory>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddHandler<THandler>(this IServiceCollection services,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||
where THandler :
|
||||
@@ -225,44 +216,4 @@ public static class IServiceCollectionExtensions
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent>(this IServiceCollection services)
|
||||
where TWidgetContent :
|
||||
IWidgetViewModel
|
||||
{
|
||||
Type contentType = typeof(TWidgetContent);
|
||||
Type templateType = typeof(IWidgetView);
|
||||
|
||||
string key = contentType.Name;
|
||||
|
||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||
services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!);
|
||||
|
||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||
services.TryAddKeyedTransient(key, (provider, key) => provider.GetService<IWidgetView>()!);
|
||||
|
||||
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent, TWidgetTemplate>(this IServiceCollection services)
|
||||
where TWidgetContent :
|
||||
IWidgetViewModel
|
||||
{
|
||||
Type contentType = typeof(TWidgetContent);
|
||||
Type templateType = typeof(TWidgetTemplate);
|
||||
|
||||
string key = contentType.Name;
|
||||
|
||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||
services.TryAddTransient(templateType);
|
||||
|
||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||
services.TryAddKeyedTransient(templateType, key);
|
||||
|
||||
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user