Exemplo n.º 1
0
 /// <summary>
 /// 获取属性或字段
 /// </summary>
 /// <param name="value"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 public Object GetPropertyOrField(Object value, String propertyName)
 {
     if (value != null)
     {
         GetPropertyOrFieldDelegate d = CreateGetPropertyOrFieldProxy(value, propertyName);
         return(d(value, propertyName));
     }
     return(null);
 }
Exemplo n.º 2
0
        private GetPropertyOrFieldDelegate CreateGetPropertyOrFieldProxy(Object value, String propertyName)
        {
            Type   type = value.GetType();
            String key;

            if (isNumberRegex.Match(propertyName).Success)
            {
                key = String.Concat("Dynamic.IL.GetPropertyOrField.", type.FullName, ".get_Item");
            }
            else
            {
                key = String.Concat("Dynamic.IL.GetPropertyOrField.", type.FullName, ".", propertyName);
            }
            Object result;

            if ((result = Engine.Cache.Get(key)) != null)
            {
                return((GetPropertyOrFieldDelegate)result);
            }
            GetPropertyOrFieldDelegate gpf = CreateGetPropertyOrFieldProxy(type, value, propertyName);

            Engine.Cache.Set(key, gpf);
            return(gpf);
        }