# 关于 SanerFrame 的记录

此文用于记录关于 SanerFreame 的一些思考。

# 关于 IOC 容器

使用 this.GetModel 来获取模型。

private readonly Dictionary<Type, object> Instances = new Dictionary<Type, object>();
        private readonly Dictionary<string, object> InstanceByNames = new Dictionary<string, object>();
        
        /// <summary>
        /// 注册实例
        /// </summary>
        /// <param name="instance"> 要注册的实例 & lt;/param>
        /// <typeparam name="T"></typeparam>
        public void Register<T>(T instance)
        {
            var key = typeof(T);
            if (Instances.ContainsKey(key))
                Instances[key] = instance;
            else 
                Instances.Add(key,instance);
        }
        
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Get<T>() where T : class
        {
            var key = typeof(T);
            if (Instances.TryGetValue(key, out var retObj)) return retObj as T;
            return null;
        }

# 关于数据请求的使用

# 模型

数据使用的模型需要继承自 AbstractModel , 使用 this.GetModel<T>() 取得。

# 命令

命令是一次请求。继承 RequestCommand , 重写本地和网络的方法 使用 this.SendComman(RequestCommand cmmand) 来执行。

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

Fasty 微信支付

微信支付

Fasty 支付宝

支付宝

Fasty 贝宝

贝宝