Exemplo n.º 1
0
 public NonSerializedAttributeInfo(DmdFieldInfo field)
 {
     if ((field.Attributes & DmdFieldAttributes.NotSerialized) != 0)
     {
         var caType = field.AppDomain.GetWellKnownType(DmdWellKnownType.System_NonSerializedAttribute, isOptional: true);
         ctor = caType?.GetConstructor(Array.Empty <DmdType>());
         Debug.Assert((object)caType == null || (object)ctor != null);
     }
     else
     {
         ctor = null;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Compares two fields
        /// </summary>
        /// <param name="a">First field</param>
        /// <param name="b">Second field</param>
        /// <returns></returns>
        public bool Equals(DmdFieldInfo a, DmdFieldInfo b)
        {
            if ((object)a == b)
            {
                return(true);
            }
            if ((object)a == null || (object)b == null)
            {
                return(false);
            }

            return(MemberNameEquals(a.Name, b.Name) &&
                   Equals(a.FieldType, b.FieldType) &&
                   (!CompareDeclaringType || Equals(a.DeclaringType, b.DeclaringType)));
        }
Exemplo n.º 3
0
 public FieldOffsetAttributeInfo(DmdFieldInfo field, uint?offset)
 {
     if (offset != null)
     {
         this.offset = (int)offset.Value;
         var caType = field.AppDomain.GetWellKnownType(DmdWellKnownType.System_Runtime_InteropServices_FieldOffsetAttribute, isOptional: true);
         ctor = caType?.GetConstructor(new[] { field.AppDomain.System_Int32 });
         Debug.Assert((object)caType == null || (object)ctor != null);
     }
     else
     {
         ctor        = null;
         this.offset = 0;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the hash code of a field
        /// </summary>
        /// <param name="a">Field</param>
        /// <returns></returns>
        public int GetHashCode(DmdFieldInfo a)
        {
            if ((object)a == null)
            {
                return(0);
            }

            int hc = MemberNameGetHashCode(a.Name);

            hc ^= GetHashCode(a.FieldType);
            if (CompareDeclaringType)
            {
                hc ^= GetHashCode(a.DeclaringType);
            }
            return(hc);
        }
Exemplo n.º 5
0
 void Write(DmdFieldInfo field)
 {
     FormatTypeName(field.FieldType, GetTypeFlags(true) | TypeFlags.FnPtrIsIntPtr);
     writer.Append(' ');
     writer.Append(field.Name);
 }
Exemplo n.º 6
0
 string FormatCore(DmdFieldInfo field)
 {
     Write(field);
     return(writer.ToString());
 }
Exemplo n.º 7
0
 public static string Format(DmdFieldInfo field, bool serializable = false)
 {
     using (var formatter = new DmdMemberFormatter(serializable ? GlobalFlags.Serializable : GlobalFlags.None))
         return(formatter.FormatCore(field));
 }
Exemplo n.º 8
0
 public MarshalAsAttributeInfo(DmdFieldInfo field, DmdMarshalType marshalType) => ctor         = Initialize(field.AppDomain, marshalType);
Exemplo n.º 9
0
 /// <summary>
 /// Stores a value in a field
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="field">Field</param>
 /// <param name="obj">Instance object or null if it's a static field</param>
 /// <param name="value">Value to store in the field</param>
 public abstract void StoreField(object context, DmdFieldInfo field, object obj, object value);
Exemplo n.º 10
0
 /// <summary>
 /// Loads a field
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="field">Field</param>
 /// <param name="obj">Instance object or null if it's a static field</param>
 /// <returns></returns>
 public abstract object LoadField(object context, DmdFieldInfo field, object obj);
Exemplo n.º 11
0
 /// <summary>
 /// Stores a value in a field
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="field">Field</param>
 /// <param name="obj">Instance object or null if it's a static field</param>
 /// <param name="value">Value to store in the field</param>
 /// <param name="callback">Notified when the method is complete</param>
 public abstract void StoreField(object context, DmdFieldInfo field, object obj, object value, Action callback);
Exemplo n.º 12
0
 /// <summary>
 /// Loads a field
 /// </summary>
 /// <param name="context">Evaluation context</param>
 /// <param name="field">Field</param>
 /// <param name="obj">Instance object or null if it's a static field</param>
 /// <param name="callback">Notified when the method is complete</param>
 public abstract void LoadField(object context, DmdFieldInfo field, object obj, Action <object> callback);
Exemplo n.º 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="field">Field that couldn't be resolved</param>
 public FieldResolveException(DmdFieldInfo field) : base("Couldn't resolve field: " + field.ToString() + ", type: " + field.DeclaringType !.ToString()) => Field = field;