private static FieldInfo GetFieldInfo(Type type, string name, BindingFlags bindingAttr)
 {
     if ((s_cbmTdpBridge != null) && IsFrameworkType(type))
     {
         Type typeToUseForCBMBridge = GetTypeToUseForCBMBridge(type);
         if (s_cbmTdpBridge.HasField(typeToUseForCBMBridge, name, bindingAttr))
         {
             return(type.GetField(name, bindingAttr));
         }
         return(null);
     }
     if (GetReflectionType(type).GetField(name, bindingAttr) != null)
     {
         return(type.GetField(name, bindingAttr));
     }
     return(null);
 }
예제 #2
0
        private static FieldInfo GetFieldInfo(Type type, string name, BindingFlags bindingAttr)
        {
            if (s_cbmTdpBridge != null && IsFrameworkType(type))
            {
                Type typeToUse = GetTypeToUseForCBMBridge(type);
                bool hasField  = s_cbmTdpBridge.HasField(typeToUse, name, bindingAttr);
                if (hasField)
                {
                    return(type.GetField(name, bindingAttr));
                }
                return(null);
            }

            Type      targetFrameworkType = GetReflectionType(type);
            FieldInfo fieldInfo           = targetFrameworkType.GetField(name, bindingAttr);

            // Return the actual runtime FieldInfo only if it was found in the target type.
            if (fieldInfo != null)
            {
                return(type.GetField(name, bindingAttr));
            }
            return(null);
        }