Exemple #1
0
 private static bool ObjectDrawerForType(Type _fieldType, ref FieldDrawer _fieldDrawer, ref Type _fieldDrawerType, int _hash)
 {
     ObjectDrawerUtility.BuildObjectDrawers();
     if (!ObjectDrawerUtility.objectDrawerTypeMap.ContainsKey(_fieldType))
     {
         return(false);
     }
     _fieldDrawerType = ObjectDrawerUtility.objectDrawerTypeMap[_fieldType];
     if (ObjectDrawerUtility.objectDrawerMap.ContainsKey(_hash))
     {
         _fieldDrawer = ObjectDrawerUtility.objectDrawerMap[_hash];
     }
     return(true);
 }
 private static bool ObjectDrawerForType(Type type, ref FieldDrawer objectDrawer, ref Type objectDrawerType, int hash)
 {
     ObjectDrawerUtility.BuildObjectDrawers();
     if (!ObjectDrawerUtility.objectDrawerTypeMap.ContainsKey(type))
     {
         return(false);
     }
     objectDrawerType = ObjectDrawerUtility.objectDrawerTypeMap[type];
     if (ObjectDrawerUtility.objectDrawerMap.ContainsKey(hash))
     {
         objectDrawer = ObjectDrawerUtility.objectDrawerMap[hash];
     }
     return(true);
 }
Exemple #3
0
        public static FieldDrawer GetObjectDrawer(FieldInfo _fieldInfo)
        {
            FieldDrawer objectDrawer = null;
            Type        type         = null;

            if (!ObjectDrawerUtility.ObjectDrawerForType(_fieldInfo.FieldType, ref objectDrawer, ref type, _fieldInfo.GetHashCode()))
            {
                return(null);
            }
            if (objectDrawer == null)
            {
                objectDrawer = (Activator.CreateInstance(type) as FieldDrawer);
                ObjectDrawerUtility.objectDrawerMap.Add(_fieldInfo.GetHashCode(), objectDrawer);
            }
            objectDrawer.FieldInfo = _fieldInfo;
            return(objectDrawer);
        }
Exemple #4
0
        public static FieldDrawer GetObjectDrawer(FieldAttribute attribute)
        {
            FieldDrawer objectDrawer = null;
            Type        type         = null;

            if (!ObjectDrawerUtility.ObjectDrawerForType(attribute.GetType(), ref objectDrawer, ref type, attribute.GetHashCode()))
            {
                return(null);
            }
            if (objectDrawer != null)
            {
                return(objectDrawer);
            }
            objectDrawer           = (Activator.CreateInstance(type) as FieldDrawer);
            objectDrawer.Attribute = attribute;
            ObjectDrawerUtility.objectDrawerMap.Add(attribute.GetHashCode(), objectDrawer);
            return(objectDrawer);
        }