增加Prism 框架

This commit is contained in:
chfei committed 2026-08-31 16:28:23 +08:00
1 parent 2cd6b8db86
commit 726eb6de16
99 files changed
+12527

No files matched your search

@@ -0,0 +1,36 @@
using MAX.Core.Infrastructure;
using System;
using System.Collections.Concurrent;
namespace MAX.Core.DependencyInjection;
public interface ILazyServiceProvider
{
object LazyGetService(Type serviceType);
T LazyGetService<T>();
}
public class LazyServiceProvider : SingleInstance<LazyServiceProvider>, ILazyServiceProvider
{
protected ConcurrentDictionary<Type, Lazy<object>> CachedServices { get; }
private LazyServiceProvider()
{
CachedServices = new ConcurrentDictionary<Type, Lazy<object>>();
}
public virtual T LazyGetService<T>()
{
return (T)LazyGetService(typeof(T));
}
public virtual object LazyGetService(Type serviceType)
{
return GetService(serviceType);
}
public virtual object GetService(Type serviceType)
{
return CachedServices.GetOrAdd(
serviceType,
_ => new Lazy<object>(() => IocManager.Resolve(serviceType))
).Value;
}
}