Наследование: System.Reflection.FieldInfo
        internal static void SerializationSetValue(MemberInfo fi, object target, object value)
        {
            RtFieldInfo info = fi as RtFieldInfo;

            if (info != null)
            {
                info.InternalSetValue(target, value, BindingFlags.Default, s_binder, null, false);
            }
            else
            {
                SerializationFieldInfo info2 = fi as SerializationFieldInfo;
                if (info2 == null)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldInfo"));
                }
                info2.InternalSetValue(target, value, BindingFlags.Default, s_binder, null, false, true);
            }
        }
Пример #2
0
        internal static void SerializationSetValue(MemberInfo fi, object target, object value)
        {
            RtFieldInfo rtFieldInfo = fi as RtFieldInfo;

            if (rtFieldInfo != null)
            {
                rtFieldInfo.CheckConsistency(target);
                rtFieldInfo.UnsafeSetValue(target, value, BindingFlags.Default, FormatterServices.s_binder, null);
                return;
            }
            SerializationFieldInfo serializationFieldInfo = fi as SerializationFieldInfo;

            if (serializationFieldInfo != null)
            {
                serializationFieldInfo.InternalSetValue(target, value, BindingFlags.Default, FormatterServices.s_binder, null);
                return;
            }
            throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldInfo"));
        }
Пример #3
0
        internal static void SerializationSetValue(MemberInfo fi, Object target, Object value)
        {
            Contract.Requires(fi != null);

            RtFieldInfo rtField = fi as RtFieldInfo;

            if (rtField != null)
            {
                rtField.CheckConsistency(target);
                rtField.UnsafeSetValue(target, value, BindingFlags.Default, s_binder, null);
                return;
            }

            SerializationFieldInfo serField = fi as SerializationFieldInfo;

            if (serField != null)
            {
                serField.InternalSetValue(target, value, BindingFlags.Default, s_binder, null);
                return;
            }

            throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldInfo"));
        }
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] array = new FieldInfo[4];
            int         num   = 0;

            int[]  array2      = null;
            object objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if (num + 1 >= array.Length)
                {
                    FieldInfo[] array3 = new FieldInfo[array.Length * 2];
                    Array.Copy(array, array3, array.Length);
                    array = array3;
                }
                ValueTypeFixupInfo valueFixup = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != null)
                {
                    FieldInfo    parentField  = valueFixup.ParentField;
                    ObjectHolder objectHolder = this.FindObjectHolder(valueFixup.ContainerID);
                    if (objectHolder.ObjectValue == null)
                    {
                        break;
                    }
                    if (Nullable.GetUnderlyingType(parentField.FieldType) != null)
                    {
                        array[num] = parentField.FieldType.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);
                        num++;
                    }
                    array[num] = parentField;
                    holder     = objectHolder;
                    num++;
                }
                else
                {
                    holder = this.FindObjectHolder(valueFixup.ContainerID);
                    array2 = valueFixup.ParentIndex;
                    if (holder.ObjectValue == null)
                    {
                        break;
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && holder.ObjectValue != null)
            {
                objectValue = holder.ObjectValue;
            }
            if (num != 0)
            {
                FieldInfo[] array4 = new FieldInfo[num];
                for (int i = 0; i < num; i++)
                {
                    FieldInfo fieldInfo = array[num - 1 - i];
                    SerializationFieldInfo serializationFieldInfo = fieldInfo as SerializationFieldInfo;
                    array4[i] = ((serializationFieldInfo == null) ? fieldInfo : serializationFieldInfo.FieldInfo);
                }
                TypedReference typedReference = TypedReference.MakeTypedReference(objectValue, array4);
                if (memberToFix != null)
                {
                    ((RuntimeFieldInfo)memberToFix).SetValueDirect(typedReference, value);
                }
                else
                {
                    TypedReference.SetTypedReference(typedReference, value);
                }
            }
            else if (memberToFix != null)
            {
                FormatterServices.SerializationSetValue(memberToFix, objectValue, value);
            }
            if (array2 != null && holder.ObjectValue != null)
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, array2);
            }
            return(true);
        }
Пример #5
0
		internal RemotingFieldCachedData(SerializationFieldInfo ri)
		{
		}		
Пример #6
0
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] sourceArray = new FieldInfo[4];
            FieldInfo[] flds        = null;
            int         index       = 0;

            int[] indices = null;
            ValueTypeFixupInfo valueFixup  = null;
            object             objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if ((index + 1) >= sourceArray.Length)
                {
                    FieldInfo[] destinationArray = new FieldInfo[sourceArray.Length * 2];
                    Array.Copy(sourceArray, destinationArray, sourceArray.Length);
                    sourceArray = destinationArray;
                }
                valueFixup  = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != null)
                {
                    FieldInfo    parentField = valueFixup.ParentField;
                    ObjectHolder holder2     = this.FindObjectHolder(valueFixup.ContainerID);
                    if (holder2.ObjectValue == null)
                    {
                        break;
                    }
                    if (Nullable.GetUnderlyingType(parentField.FieldType) != null)
                    {
                        sourceArray[index] = parentField.FieldType.GetField("value", BindingFlags.NonPublic | BindingFlags.Instance);
                        index++;
                    }
                    sourceArray[index] = parentField;
                    holder             = holder2;
                    index++;
                }
                else
                {
                    holder  = this.FindObjectHolder(valueFixup.ContainerID);
                    indices = valueFixup.ParentIndex;
                    if (holder.ObjectValue != null)
                    {
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && (holder.ObjectValue != null))
            {
                objectValue = holder.ObjectValue;
            }
            if (index != 0)
            {
                flds = new FieldInfo[index];
                for (int i = 0; i < index; i++)
                {
                    FieldInfo info3 = sourceArray[(index - 1) - i];
                    SerializationFieldInfo info4 = info3 as SerializationFieldInfo;
                    flds[i] = (info4 == null) ? info3 : info4.FieldInfo;
                }
                TypedReference reference = TypedReference.MakeTypedReference(objectValue, flds);
                if (memberToFix != null)
                {
                    ((RuntimeFieldInfo)memberToFix).SetValueDirect(reference, value);
                }
                else
                {
                    TypedReference.SetTypedReference(reference, value);
                }
            }
            else if (memberToFix != null)
            {
                FormatterServices.SerializationSetValue(memberToFix, objectValue, value);
            }
            if ((indices != null) && (holder.ObjectValue != null))
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, indices);
            }
            return(true);
        }
 internal RemotingCachedData(SerializationFieldInfo ri)
 {
     this.RI = ri;
 }
Пример #8
0
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] fieldInfoArray1 = new FieldInfo[4];
            int         length          = 0;

            int[]  numArray    = (int[])null;
            object objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if (length + 1 >= fieldInfoArray1.Length)
                {
                    FieldInfo[] fieldInfoArray2 = new FieldInfo[fieldInfoArray1.Length * 2];
                    Array.Copy((Array)fieldInfoArray1, (Array)fieldInfoArray2, fieldInfoArray1.Length);
                    fieldInfoArray1 = fieldInfoArray2;
                }
                ValueTypeFixupInfo valueFixup = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != (FieldInfo)null)
                {
                    FieldInfo    parentField  = valueFixup.ParentField;
                    ObjectHolder objectHolder = this.FindObjectHolder(valueFixup.ContainerID);
                    if (objectHolder.ObjectValue != null)
                    {
                        if (Nullable.GetUnderlyingType(parentField.FieldType) != (Type)null)
                        {
                            fieldInfoArray1[length] = parentField.FieldType.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);
                            ++length;
                        }
                        fieldInfoArray1[length] = parentField;
                        holder = objectHolder;
                        ++length;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    holder   = this.FindObjectHolder(valueFixup.ContainerID);
                    numArray = valueFixup.ParentIndex;
                    if (holder.ObjectValue != null)
                    {
                        break;
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && holder.ObjectValue != null)
            {
                objectValue = holder.ObjectValue;
            }
            if (length != 0)
            {
                FieldInfo[] flds = new FieldInfo[length];
                for (int index = 0; index < length; ++index)
                {
                    FieldInfo fieldInfo = fieldInfoArray1[length - 1 - index];
                    SerializationFieldInfo serializationFieldInfo = fieldInfo as SerializationFieldInfo;
                    flds[index] = (FieldInfo)serializationFieldInfo == (FieldInfo)null ? fieldInfo : (FieldInfo)serializationFieldInfo.FieldInfo;
                }
                TypedReference target = TypedReference.MakeTypedReference(objectValue, flds);
                if (memberToFix != (FieldInfo)null)
                {
                    memberToFix.SetValueDirect(target, value);
                }
                else
                {
                    TypedReference.SetTypedReference(target, value);
                }
            }
            else if (memberToFix != (FieldInfo)null)
            {
                FormatterServices.SerializationSetValue((MemberInfo)memberToFix, objectValue, value);
            }
            if (numArray != null && holder.ObjectValue != null)
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, numArray);
            }
            return(true);
        }