示例#1
0
        /// <summary>
        /// 按照是否包含并且变化决定调用处理程序(如果模型中确实包含某属性,并且确实检测到变化,才调用处理程序)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="hashModel"></param>
        /// <param name="key"></param>
        /// <param name="proecessAction"></param>
        public static void AutoProcessProperty <T>(this IHashDictionary hashModel, string key, Action <T> proecessAction)
        {
            var value = hashModel.GetValueAs <T>(key);

            if (value != null && hashModel.CheckChanged(key))
            {
                proecessAction(value);
            }
        }
示例#2
0
        /// <summary>
        /// 按照是否包含并且变化决定调用处理程序(如果模型中确实包含某属性,并且确实检测到变化,才调用处理程序)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="hashModel"></param>
        /// <param name="key"></param>
        /// <param name="proecessFunc"></param>
        public static TResult AutoProcessProperty <T, TResult>(this IHashDictionary hashModel, string key, Func <T, TResult> proecessFunc)
        {
            var value = hashModel.GetValueAs <T>(key);

            if (value != null && hashModel.CheckChanged(key))
            {
                return(proecessFunc(value));
            }
            return(default(TResult));
        }