Add wallet profile image loading
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Toolkit.Avalonia;
|
||||
public class ImageReader(IImageResizer imageResizer) :
|
||||
IImageReader
|
||||
{
|
||||
public async Task<IImageDescriptor> Get(Stream stream,
|
||||
public IImageDescriptor Get(Stream stream,
|
||||
int width,
|
||||
int height,
|
||||
bool maintainAspectRatio)
|
||||
|
||||
@@ -6,14 +6,15 @@ public class AppService(IEnumerable<IInitialization> initializers,
|
||||
IPublisher publisher) :
|
||||
IHostedService
|
||||
{
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (IInitialization initializer in initializers)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
initializer.Initialize();
|
||||
}
|
||||
|
||||
publisher.Publish<StartedEventArgs>();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record CancelEventArgs<TSender>(TSender sender);
|
||||
public record CancelEventArgs<TSender>(TSender Sender);
|
||||
@@ -14,7 +14,8 @@ public class ComponentHost(IServiceProvider services,
|
||||
{
|
||||
}
|
||||
|
||||
public TConfiguration? GetConfiguration<TConfiguration>() where TConfiguration : ComponentConfiguration
|
||||
public TConfiguration? GetConfiguration<TConfiguration>()
|
||||
where TConfiguration : ComponentConfiguration
|
||||
{
|
||||
return Services.GetService<TConfiguration>();
|
||||
}
|
||||
@@ -23,7 +24,7 @@ public class ComponentHost(IServiceProvider services,
|
||||
{
|
||||
foreach (IInitialization initializer in initializers)
|
||||
{
|
||||
await initializer.Initialize();
|
||||
initializer.Initialize();
|
||||
}
|
||||
|
||||
foreach (IHostedService service in hostedServices)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
@@ -9,7 +10,7 @@ public class ComponentInitializer(IEnumerable<IComponent> components,
|
||||
IServiceProvider provider) :
|
||||
IInitialization
|
||||
{
|
||||
public async Task Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
foreach (IComponent component in components)
|
||||
{
|
||||
@@ -45,7 +46,7 @@ public class ComponentInitializer(IEnumerable<IComponent> components,
|
||||
provider.GetRequiredService<IServiceProvider>()));
|
||||
|
||||
hosts.Add(host);
|
||||
await host.StartAsync();
|
||||
host.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class ConfigurationInitializer<TConfiguration>(IConfigurationReader<TConf
|
||||
where TConfiguration :
|
||||
class
|
||||
{
|
||||
public Task Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
if (!reader.TryRead(out TConfiguration? configuration))
|
||||
{
|
||||
@@ -21,6 +21,5 @@ public class ConfigurationInitializer<TConfiguration>(IConfigurationReader<TConf
|
||||
}
|
||||
|
||||
publisher.PublishUI(new ActivatedEventArgs<TConfiguration>(configuration));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IAsyncInitialization
|
||||
{
|
||||
Task Initialize();
|
||||
}
|
||||
@@ -4,5 +4,5 @@ public interface IConfigurationInitializer<TConfiguration>
|
||||
where TConfiguration :
|
||||
class
|
||||
{
|
||||
Task Initialize();
|
||||
void Initialize();
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
public interface IImageReader
|
||||
{
|
||||
Task<IImageDescriptor> Get(Stream stream,
|
||||
IImageDescriptor Get(Stream stream,
|
||||
int width,
|
||||
int height,
|
||||
bool maintainAspectRatio = false);
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public interface IInitialization
|
||||
{
|
||||
Task Initialize();
|
||||
}
|
||||
void Initialize();
|
||||
}
|
||||
|
||||
@@ -56,17 +56,15 @@ public partial class Observable(IServiceProvider provider,
|
||||
Disposer.Dispose(this);
|
||||
}
|
||||
|
||||
public virtual Task Initialize()
|
||||
public virtual void Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
|
||||
Subscriber.Subscribe(this);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
|
||||
@@ -157,8 +157,7 @@ public partial class ObservableCollection<TItem> :
|
||||
}
|
||||
|
||||
public TItem Add<T>(params object?[] parameters)
|
||||
where T :
|
||||
TItem
|
||||
where T : TItem
|
||||
{
|
||||
T? item = Factory.Create<T>(args =>
|
||||
{
|
||||
@@ -416,19 +415,17 @@ public partial class ObservableCollection<TItem> :
|
||||
IsCompatibleObject(value) ?
|
||||
IndexOf((TItem)value!) : -1;
|
||||
|
||||
public virtual Task Initialize()
|
||||
public virtual void Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
|
||||
Subscriber.Subscribe(this);
|
||||
Synchronize();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public TItem Insert<T>(int index = 0,
|
||||
|
||||
Reference in New Issue
Block a user