Files
2026-06-04 11:42:34 +02:00

222 lines
5.9 KiB
C#

using System;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace System.Reflection
{
// Token: 0x02000255 RID: 597
[Serializable]
internal class MonoField : FieldInfo, ISerializable
{
// Token: 0x170005B4 RID: 1460
// (get) Token: 0x06001EE6 RID: 7910 RVA: 0x00071BF4 File Offset: 0x0006FDF4
public override FieldAttributes Attributes
{
get
{
return this.attrs;
}
}
// Token: 0x170005B5 RID: 1461
// (get) Token: 0x06001EE7 RID: 7911 RVA: 0x00071BFC File Offset: 0x0006FDFC
public override RuntimeFieldHandle FieldHandle
{
get
{
return this.fhandle;
}
}
// Token: 0x170005B6 RID: 1462
// (get) Token: 0x06001EE8 RID: 7912 RVA: 0x00071C04 File Offset: 0x0006FE04
public override Type FieldType
{
get
{
return this.type;
}
}
// Token: 0x06001EE9 RID: 7913
[MethodImpl(MethodImplOptions.InternalCall)]
private extern Type GetParentType(bool declaring);
// Token: 0x170005B7 RID: 1463
// (get) Token: 0x06001EEA RID: 7914 RVA: 0x00071C0C File Offset: 0x0006FE0C
public override Type ReflectedType
{
get
{
return this.GetParentType(false);
}
}
// Token: 0x170005B8 RID: 1464
// (get) Token: 0x06001EEB RID: 7915 RVA: 0x00071C18 File Offset: 0x0006FE18
public override Type DeclaringType
{
get
{
return this.GetParentType(true);
}
}
// Token: 0x170005B9 RID: 1465
// (get) Token: 0x06001EEC RID: 7916 RVA: 0x00071C24 File Offset: 0x0006FE24
public override string Name
{
get
{
return this.name;
}
}
// Token: 0x06001EED RID: 7917 RVA: 0x00071C2C File Offset: 0x0006FE2C
public override bool IsDefined(Type attributeType, bool inherit)
{
return MonoCustomAttrs.IsDefined(this, attributeType, inherit);
}
// Token: 0x06001EEE RID: 7918 RVA: 0x00071C38 File Offset: 0x0006FE38
public override object[] GetCustomAttributes(bool inherit)
{
return MonoCustomAttrs.GetCustomAttributes(this, inherit);
}
// Token: 0x06001EEF RID: 7919 RVA: 0x00071C44 File Offset: 0x0006FE44
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
return MonoCustomAttrs.GetCustomAttributes(this, attributeType, inherit);
}
// Token: 0x06001EF0 RID: 7920
[MethodImpl(MethodImplOptions.InternalCall)]
internal override extern int GetFieldOffset();
// Token: 0x06001EF1 RID: 7921
[MethodImpl(MethodImplOptions.InternalCall)]
private extern object GetValueInternal(object obj);
// Token: 0x06001EF2 RID: 7922 RVA: 0x00071C50 File Offset: 0x0006FE50
public override object GetValue(object obj)
{
if (!this.IsStatic)
{
if (obj == null)
{
throw new TargetException("Non-static field requires a target");
}
if (!this.DeclaringType.IsAssignableFrom(obj.GetType()))
{
throw new ArgumentException(string.Format("Field {0} defined on type {1} is not a field on the target object which is of type {2}.", this.Name, this.DeclaringType, obj.GetType()), "obj");
}
}
if (!this.IsLiteral)
{
this.CheckGeneric();
}
return this.GetValueInternal(obj);
}
// Token: 0x06001EF3 RID: 7923 RVA: 0x00071CD0 File Offset: 0x0006FED0
public override string ToString()
{
return string.Format("{0} {1}", this.type, this.name);
}
// Token: 0x06001EF4 RID: 7924
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void SetValueInternal(FieldInfo fi, object obj, object value);
// Token: 0x06001EF5 RID: 7925 RVA: 0x00071CE8 File Offset: 0x0006FEE8
public override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
{
if (!this.IsStatic)
{
if (obj == null)
{
throw new TargetException("Non-static field requires a target");
}
if (!this.DeclaringType.IsAssignableFrom(obj.GetType()))
{
throw new ArgumentException(string.Format("Field {0} defined on type {1} is not a field on the target object which is of type {2}.", this.Name, this.DeclaringType, obj.GetType()), "obj");
}
}
if (this.IsLiteral)
{
throw new FieldAccessException("Cannot set a constant field");
}
if (binder == null)
{
binder = Binder.DefaultBinder;
}
this.CheckGeneric();
if (val != null)
{
object obj2 = binder.ChangeType(val, this.type, culture);
if (obj2 == null)
{
throw new ArgumentException(string.Concat(new object[]
{
"Object type ",
val.GetType(),
" cannot be converted to target type: ",
this.type
}), "val");
}
val = obj2;
}
MonoField.SetValueInternal(this, obj, val);
}
// Token: 0x06001EF6 RID: 7926 RVA: 0x00071DD8 File Offset: 0x0006FFD8
internal MonoField Clone(string newName)
{
return new MonoField
{
name = newName,
type = this.type,
attrs = this.attrs,
klass = this.klass,
fhandle = this.fhandle
};
}
// Token: 0x06001EF7 RID: 7927 RVA: 0x00071E24 File Offset: 0x00070024
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
MemberInfoSerializationHolder.Serialize(info, this.Name, this.ReflectedType, this.ToString(), MemberTypes.Field);
}
// Token: 0x06001EF8 RID: 7928
[MethodImpl(MethodImplOptions.InternalCall)]
public override extern object GetRawConstantValue();
// Token: 0x06001EF9 RID: 7929 RVA: 0x00071E4C File Offset: 0x0007004C
private void CheckGeneric()
{
if (this.DeclaringType.ContainsGenericParameters)
{
throw new InvalidOperationException("Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.");
}
}
// Token: 0x04000ABC RID: 2748
internal IntPtr klass;
// Token: 0x04000ABD RID: 2749
internal RuntimeFieldHandle fhandle;
// Token: 0x04000ABE RID: 2750
private string name;
// Token: 0x04000ABF RID: 2751
private Type type;
// Token: 0x04000AC0 RID: 2752
private FieldAttributes attrs;
}
}