Наследование: PythonTypeSlot, ICodeFormattable
Пример #1
0
 public BuiltinFieldInfo(ReflectedField value, ProjectState projectState)
     : base(new LazyDotNetDict(ClrModule.GetPythonType(value.FieldType), projectState, true))
 {
     _value = value;
     _doc = null;
     _type = ClrModule.GetPythonType(value.FieldType);
 }
Пример #2
0
        internal static PythonTypeSlot GetReflectedField(FieldInfo info) {
            PythonTypeSlot res;

            NameType nt = NameType.Field;
            if (!PythonBinder.IsExtendedType(info.DeclaringType) && 
                !info.IsDefined(typeof(PythonHiddenAttribute), false)) {
                nt |= NameType.PythonField;
            }

            lock (_fieldCache) {
                if (!_fieldCache.TryGetValue(info, out res)) {
                    if (nt == NameType.PythonField && info.IsLiteral) {
                        if (info.FieldType == typeof(int)) {
                            res = new PythonTypeUserDescriptorSlot(
                                ScriptingRuntimeHelpers.Int32ToObject((int)info.GetRawConstantValue()),
                                true
                            );
                        } else if (info.FieldType == typeof(bool)) {
                            res = new PythonTypeUserDescriptorSlot(
                                ScriptingRuntimeHelpers.BooleanToObject((bool)info.GetRawConstantValue()),
                                true
                            );
                        } else {
                            res = new PythonTypeUserDescriptorSlot(
                                info.GetValue(null),
                                true
                            );
                        }
                    } else {
                        res = new ReflectedField(info, nt);
                    }

                    _fieldCache[info] = res;
                }
            }

            return res;
        }
Пример #3
0
        internal static ReflectedField GetReflectedField(FieldInfo info) {
            ReflectedField res;

            NameType nt = NameType.Field;
            if (!PythonBinder.IsExtendedType(info.DeclaringType) && 
                !info.IsDefined(typeof(PythonHiddenAttribute), false)) {
                nt |= NameType.PythonField;
            }

            lock (_fieldCache) {
                if (!_fieldCache.TryGetValue(info, out res)) {
                    _fieldCache[info] = res = new ReflectedField(info, nt);
                }
            }

            return res;
        }