﻿namespace NetCreditHub.Dependency
{
    using System;

    /// <summary>
    /// 获取那些可以使用 <see cref="IocManager.Instance"/> 解析的类的单例.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public static class SingletonDependency<T>
    {
        private static readonly Lazy<T> LazyInstance;

        /// <summary>
        /// 获取实例.
        /// </summary>
        public static T Instance => LazyInstance.Value;

        static SingletonDependency()
        {
            LazyInstance = new Lazy<T>(() => IocManager.Instance.Resolve<T>());
        }
    }
}
