Beispiel #1
0
        private static List <FieldInfoHandle> GetFieldInfos(Type objType)
        {
            string key = objType.FullName;
            List <FieldInfoHandle> ret = null;



            if (!_dicFieldInfo.TryGetValue(key, out ret))
            {
                ret = new List <FieldInfoHandle>();
                _dicFieldInfo[key] = ret;

                Type currentType = objType;

                while (currentType != null)
                {
                    FieldInfo[] fInfos = currentType.GetFields(FastValueGetSet.AllBindingFlags);
                    foreach (FieldInfo finfo in fInfos)
                    {
                        GetFieldValueHandle getHandle = FastFieldGetSet.GetGetValueHandle(finfo);
                        SetFieldValueHandle setHandle = FastFieldGetSet.GetSetValueHandle(finfo);
                        FieldInfoHandle     handle    = new FieldInfoHandle(objType, getHandle, setHandle, finfo.FieldType, finfo.Name, finfo);
                        ret.Add(handle);
                    }
                    currentType = currentType.BaseType;
                    if (currentType == typeof(object))
                    {
                        break;
                    }
                }
            }

            return(ret);
        }
Beispiel #2
0
        public void Init(HttpApplication context)
        {
            PropertyInfoHandle  fileChangesMonitorGet = FastValueGetSet.GetPropertyInfoHandle("FileChangesMonitor", typeof(HttpRuntime));
            object              o       = fileChangesMonitorGet.GetValue(null);
            GetFieldValueHandle f       = FastFieldGetSet.FindGetValueHandle(o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase));
            object              monitor = f(o);
            FastInvokeHandler   m       = FastValueGetSet.GetCustomerMethodInfo(monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic));

            m.Invoke(monitor, new object[] { });
        }
Beispiel #3
0
        /// <summary>
        /// 初始化类型的属性信息
        /// </summary>
        /// <param name="type">类型</param>
        /// <returns>如果已经初始化过侧返回false</returns>
        private static void InitClassPropertyInfos(Type type)
        {
            string fullName = type.FullName;

            //实例化本类型的句柄
            CreateInstanceHandler createrHandel = FastValueGetSet.GetCreateInstanceHandlerWithOutCache(type);
            Dictionary <string, PropertyInfoHandle> dicPropertys = new Dictionary <string, PropertyInfoHandle>();
            Dictionary <string, FieldInfoHandle>    dicField     = new Dictionary <string, FieldInfoHandle>();

            //属性信息句柄
            PropertyInfo[] destproper = type.GetProperties(FastValueGetSet.AllBindingFlags);
            FieldInfo[]    allField   = type.GetFields(FastValueGetSet.AllBindingFlags);
            //int index = 0;
            ///读取属性别名
            foreach (PropertyInfo pinf in destproper)
            {
                ///通过属性来反射
                string proName = pinf.Name;

                FastPropertyHandler getHandle = FastValueGetSet.GetGetMethodInfo(proName, type);
                FastPropertyHandler setHandle = FastValueGetSet.GetSetMethodInfo(proName, type);
                if (getHandle != null || setHandle != null)
                {
                    PropertyInfoHandle classProperty = new PropertyInfoHandle(type, getHandle, setHandle, pinf.PropertyType, pinf.Name);
                    dicPropertys.Add(pinf.Name, classProperty);
                }
            }

            ///读取属性别名
            foreach (FieldInfo fInf in allField)
            {
                string proName = fInf.Name;

                GetFieldValueHandle getHandle = FastFieldGetSet.GetGetValueHandle(fInf);
                SetFieldValueHandle setHandle = FastFieldGetSet.GetSetValueHandle(fInf);
                if (getHandle != null || setHandle != null)
                {
                    FieldInfoHandle fieldInfo = new FieldInfoHandle(type, getHandle, setHandle, fInf.FieldType, fInf.Name, fInf);
                    dicField.Add(fInf.Name, fieldInfo);
                }
            }


            ClassInfoHandle classInfo = new ClassInfoHandle(type, createrHandel, dicPropertys, dicField);

            dicClass.Add(fullName, classInfo);
        }