using Autofac;
using System.Reflection;
using WmsMobileServe.Annotation;

namespace WmsMobileServe.AppRunning;

/// <summary>
/// 依赖注入的相关
/// </summary>
public class AutofacModule : Autofac.Module
{
    protected override void Load(ContainerBuilder builder)
    {
        var assembly = Assembly.GetExecutingAssembly();
        // 注册 Component
        builder.RegisterAssemblyTypes(assembly)
            .Where(w => w.GetCustomAttribute(typeof(ComponentAttribute)) != default)
            .SingleInstance(); // 注入单例
    }
}
