Exemple #1
0
        /// <summary>
        /// 从缓存中取Func,缓存没有则创建后放到缓存
        /// </summary>
        static private Func <object, object> GetFunc(System.Web.UI.TemplateControl control, string propertyExpression)
        {
            Type dataItemType = control.Page.GetDataItem().GetType();

            if (!_dicCache.ContainsKey(dataItemType))
            {
                lock (_dicCache)
                {
                    if (!_dicCache.ContainsKey(dataItemType))
                    {
                        _dicCache.Add(dataItemType, new Dictionary <string, Func <object, object> >());
                    }
                }
            }
            Dictionary <string, Func <object, object> > dic2 = _dicCache[dataItemType];

            if (!dic2.ContainsKey(propertyExpression))
            {
                lock (_dicCache)
                {
                    if (!dic2.ContainsKey(propertyExpression))
                    {
                        dic2.Add(propertyExpression, CreateFunc(dataItemType, propertyExpression));
                    }
                }
            }
            return(dic2[propertyExpression]);
        }
Exemple #2
0
 public ExpressionBuilderContext(System.Web.UI.TemplateControl templateControl)
 {
 }
Exemple #3
0
        public static object FastEval(this System.Web.UI.TemplateControl control, string propertyExpression)
        {
            Func <object, object> func = GetFunc(control, propertyExpression);

            return(func(control));
        }