/// <summary> /// 分配一个实例 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="env"></param> /// <returns></returns> public static T Allocate <T>(FrameworkEnvironment env) where T : RecyclableObject { T t = env.cycleCollection.Get <T>(); t._env = env; t.OnAllocate(); return(t); }
/// <summary> /// 分配一个实例 /// </summary> /// <param name="type"></param> /// <param name="env"></param> /// <returns></returns> public static RecyclableObject Allocate(Type type, FrameworkEnvironment env) { RecyclableObject t = env.cycleCollection.Get(type) as RecyclableObject; t._env = env; t.OnAllocate(); return(t); }
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 /// <summary> /// 实例化环境 /// </summary> /// <param name=" envType">环境类型</param> /// <returns>环境</returns> public static IEnvironment CreateEnv(EnvironmentType envType) { using (new LockWait(ref _lock)) { IEnvironment env; if (envs.TryGetValue((int)envType, out env)) { throw new Exception(string.Format("The EnvironmentType {0} is not null ", envType)); } else { env = new FrameworkEnvironment(envType); envs.Add((int)envType, env); return(env); } } }
/// <summary> /// 实例化环境 /// </summary> /// <param name="envName">环境名</param> /// <param name=" envType">环境类型</param> /// <returns>环境</returns> public static FrameworkEnvironment InitEnv(string envName, EnvironmentType envType) { switch (envType) { case EnvironmentType.Ev0: env0 = CreateEnv(envName, envType); return(env0); case EnvironmentType.Ev1: env1 = CreateEnv(envName, envType); return(env1); case EnvironmentType.Ev2: env2 = CreateEnv(envName, envType); return(env2); case EnvironmentType.Ev3: env3 = CreateEnv(envName, envType); return(env3); case EnvironmentType.Ev4: env4 = CreateEnv(envName, envType); return(env4); default: throw new Exception(string.Format("The EnvironmentType {0} Error,Please Check ", envType)); } }
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 internal FrameworkModules(FrameworkEnvironment env) : base("Framework", env, true) { }
/// <summary> /// 解除绑顶 方法 到一个环境的 Dispose /// </summary> /// <param name="action">方法</param> /// <param name="env">环境</param> public static void UnBindEnvDispose(this Action action, FrameworkEnvironment env) { env.onDispose -= action; }
/// <summary> /// 解除绑顶 方法 到一个环境的 Update /// </summary> /// <param name="action">方法</param> /// <param name="env">环境</param> public static void UnBindEnvUpdate(this Action action, FrameworkEnvironment env) { env.update -= action; }
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 /// <summary> /// 创建一个环境 /// </summary> /// <param name="envName">环境名称</param> /// <param name=" envType">环境类型</param> /// <returns>环境</returns> public static FrameworkEnvironment CreateEnv(string envName, EnvironmentType envType) { return(FrameworkEnvironment.CreateInstance(envName, envType)); }
/// <summary> /// 获取没有回收的实例 /// </summary> /// <param name="envType"></param> /// <param name="id"></param> /// <param name="obj"></param> /// <returns></returns> public static bool GetFromMemory(EnvironmentType envType, Guid id, out RecyclableObject obj) { FrameworkEnvironment _env = Framework.GetEnv(envType); return(GetFromMemory(_env, id, out obj)); }
/// <summary> /// 回收所有实例 /// </summary> /// <param name="envType"></param> public static void RecyleAll(EnvironmentType envType) { FrameworkEnvironment _env = Framework.GetEnv(envType); RecyleAll(_env); }
/// <summary> /// 通过唯一id回收对象 /// </summary> /// <param name="envType"></param> /// <param name="guid"></param> public static void RecyleByGuid(EnvironmentType envType, Guid guid) { FrameworkEnvironment _env = Framework.GetEnv(envType); RecyleByGuid(_env, guid); }
/// <summary> /// 获取没有回收的实例 /// </summary> /// <param name="env"></param> /// <param name="id"></param> /// <param name="obj"></param> /// <returns></returns> public static bool GetFromMemory(FrameworkEnvironment env, Guid id, out RecyclableObject obj) { return(env.cycleCollection.GetFromMemory(id, out obj)); }
/// <summary> /// 回收所有实例 /// </summary> /// <param name="env"></param> public static void RecyleAll(FrameworkEnvironment env) { env.cycleCollection.RecyleAll(); }
/// <summary> /// 通过唯一id回收对象 /// </summary> /// <param name="env"></param> /// <param name="guid"></param> public static void RecyleByGuid(FrameworkEnvironment env, Guid guid) { env.cycleCollection.Recyle(guid); }
/// <summary> /// 分配一个实例 /// </summary> /// <typeparam name="T"> RecyclableObject </typeparam> /// <param name=" envType"></param> /// <returns></returns> public static T Allocate <T>(EnvironmentType envType) where T : RecyclableObject { FrameworkEnvironment _env = Framework.GetEnv(envType); return(Allocate <T>(_env)); }
/// <summary> /// 分配一个实例 /// </summary> /// <param name="type">类型</param> /// <param name=" envType"></param> /// <returns></returns> public static RecyclableObject Allocate(Type type, EnvironmentType envType) { FrameworkEnvironment _env = Framework.GetEnv(envType); return(Allocate(type, _env)); }