Fish.Core/Infrastructure/Singleton.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
namespace Fish.Core
{
public class Singleton<T> : Singleton
{
static T instance;
public static T Instance
{
get { return instance; }
set
{
instance = value;
AllSingletons[typeof(T)] = value;
}
}
}
public class SingletonList<T> : Singleton<IList<T>>
{
static SingletonList()
{
Singleton<IList<T>>.Instance = new List<T>();
}
public new static IList<T> Instance
{
get { return Singleton<IList<T>>.Instance; }
}
}
public class SingletonDictionary<TKey, TValue> : Singleton<IDictionary<TKey, TValue>>
{
static SingletonDictionary()
{
Singleton<Dictionary<TKey, TValue>>.Instance = new Dictionary<TKey, TValue>();
}
public new static IDictionary<TKey, TValue> Instance
{
get { return Singleton<Dictionary<TKey, TValue>>.Instance; }
}
}
public class Singleton
{
static Singleton()
{
allSingletons = new Dictionary<Type, object>();
}
static readonly IDictionary<Type, object> allSingletons;
public static IDictionary<Type, object> AllSingletons
{
get { return allSingletons; }
}
}
后面还有 1 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。