示例#1
0
        public void Add(ICacheableModel model)
        {
            Type type      = model.GetType();
            var  reference = new WeakReference(model);

            while (!type.Equals(model.GetBaseType()))
            {
                try
                {
                    var key = new ModelIdentifier(type, model.ModelId);
                    if (this.ContainsKey(key))
                    {
                        Replace(key, reference);
                    }
                    else
                    {
                        Add(key, reference);
                    }

                    type = type.BaseType;
                }
                catch (Exception e)
                {
                    throw new AddModelDictionaryItemException(type, model.ModelId, e);
                }
            }
        }
示例#2
0
 public DictionaryModelCache(ICacheableModel model) : base(model)
 {
     cache = new Dictionary <long, T> (model.FetchCount);
 }
 public ArrayModelCache(ICacheableModel model) : base(model)
 {
     cache = new T [Model.FetchCount];
 }
示例#4
0
 public ModelCache(ICacheableModel model)
 {
     Model = model;
 }
示例#5
0
 public async Task <ICacheableModel> UpdateModelAsync(ICacheableModel model)
 {
     return(await updateFuncAsync(model));
 }
 public ModelCache(ICacheableModel model)
 {
     this.model = model;
 }
 public int GetHashCode(ICacheableModel obj)
 {
     throw new NotImplementedException();
 }
 public ModelIdentifier(ICacheableModel model)
 {
     ModelType = model.GetType();
     ModelId   = model.ModelId;
 }