示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
#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);
                }
            }
        }
示例#4
0
        /// <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));
            }
        }
示例#5
0
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释

        internal FrameworkModules(FrameworkEnvironment env) : base("Framework", env, true)
        {
        }
示例#6
0
 /// <summary>
 /// 解除绑顶 方法 到一个环境的 Dispose
 /// </summary>
 /// <param name="action">方法</param>
 /// <param name="env">环境</param>
 public static void UnBindEnvDispose(this Action action, FrameworkEnvironment env)
 {
     env.onDispose -= action;
 }
示例#7
0
 /// <summary>
 /// 解除绑顶 方法 到一个环境的 Update
 /// </summary>
 /// <param name="action">方法</param>
 /// <param name="env">环境</param>
 public static void UnBindEnvUpdate(this Action action, FrameworkEnvironment env)
 {
     env.update -= action;
 }
示例#8
0
#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));
        }
示例#9
0
        /// <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));
        }
示例#10
0
        /// <summary>
        /// 回收所有实例
        /// </summary>
        /// <param name="envType"></param>
        public static void RecyleAll(EnvironmentType envType)
        {
            FrameworkEnvironment _env = Framework.GetEnv(envType);

            RecyleAll(_env);
        }
示例#11
0
        /// <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);
        }
示例#12
0
 /// <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));
 }
示例#13
0
 /// <summary>
 /// 回收所有实例
 /// </summary>
 /// <param name="env"></param>
 public static void RecyleAll(FrameworkEnvironment env)
 {
     env.cycleCollection.RecyleAll();
 }
示例#14
0
 /// <summary>
 /// 通过唯一id回收对象
 /// </summary>
 /// <param name="env"></param>
 /// <param name="guid"></param>
 public static void RecyleByGuid(FrameworkEnvironment env, Guid guid)
 {
     env.cycleCollection.Recyle(guid);
 }
示例#15
0
        /// <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));
        }
示例#16
0
        /// <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));
        }