/// <summary> /// 缓存计数 /// </summary> /// <param name="cache"></param> /// <param name="group">数据分组</param> /// <param name="getKey">缓存关键字获取器</param> /// <param name="getByKey"></param> /// <param name="getValue"></param> /// <param name="member"></param> protected Member(Whole.Event.Cache <valueType, modelType, memberCacheType> cache, int group, Func <modelType, keyType> getKey , Func <keyType, targetType> getByKey, Func <valueType, targetType> getValue, Expression <Func <targetType, KeyValue <valueType, int> > > member) : base(cache.SqlTable, group) { if (getKey == null) { throw new ArgumentNullException("getKey is null"); } if (getByKey == null) { throw new ArgumentNullException("getByKey is null"); } if (getValue == null) { throw new ArgumentNullException("getValue is null"); } if (member == null) { throw new ArgumentNullException("member is null"); } MemberExpression <targetType, KeyValue <valueType, int> > expression = new MemberExpression <targetType, KeyValue <valueType, int> >(member); if (expression.Field == null) { throw new InvalidCastException("member is not MemberExpression"); } GetKey = getKey; GetByKey = getByKey; GetValue = getValue; GetMember = expression.GetMember; setMember = expression.SetMember; SqlTable.OnUpdated += onUpdated; cache.OnDeleted += onDeleted; }
/// <summary> /// 自增id标识缓存计数器 /// </summary> /// <param name="cache"></param> /// <param name="getByKey"></param> /// <param name="getValue"></param> /// <param name="member"></param> /// <param name="group">数据分组</param> public MemberIdentity(Whole.Event.Cache <valueType, modelType, memberCacheType> cache , Func <int, targetType> getByKey, Func <valueType, targetType> getValue, Expression <Func <targetType, KeyValue <valueType, int> > > member, int group = 1) : base(cache, group, DataModel.Model <modelType> .GetIdentity32, getByKey, getValue, member) { }