Exemplo n.º 1
0
        internal void Fixup(ParseRecord record, ParseRecord parent)
        {
            Object obj = record.PRnewObj;

#if _DEBUG
            SerTrace.Log(this, "Fixup ", obj, " ", ((Enum)valueFixupEnum).ToString());
#endif
            switch (valueFixupEnum)
            {
            case ValueFixupEnum.Array:
                arrayObj.SetValue(obj, indexMap);
                break;

            case ValueFixupEnum.Header:
                Type type = typeof(Header);
                if (valueInfo == null)
                {
                    MemberInfo[] valueInfos = type.GetMember("Value");
                    if (valueInfos.Length != 1)
                    {
                        throw new SerializationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_HeaderReflection"), valueInfos.Length));
                    }
                    valueInfo = valueInfos[0];
                }
                FormatterServices.SerializationSetValue(valueInfo, header, obj);
                break;

            case ValueFixupEnum.Member:
                SerTrace.Log(this, "Fixup Member new object value ", obj, " memberObject ", memberObject);

                if (objectInfo.isSi)
                {
                    SerTrace.Log(this, "Recording a fixup on member: ", memberName,
                                 " in object id", parent.PRobjectId, " Required Object ", record.PRobjectId);
                    objectInfo.objectManager.RecordDelayedFixup(parent.PRobjectId, memberName, record.PRobjectId);
//                          Console.WriteLine("SerializationInfo: Main Object ({0}): {1}. SubObject ({2}): {3}", parent.PRobjectId,
//                                            objectInfo.obj, record.PRobjectId, obj);
                }
                else
                {
                    MemberInfo memberInfo = objectInfo.GetMemberInfo(memberName);
                    SerTrace.Log(this, "Recording a fixup on member:", memberInfo, " in object id ",
                                 parent.PRobjectId, " Required Object", record.PRobjectId);
                    if (memberInfo != null)
                    {
                        objectInfo.objectManager.RecordFixup(parent.PRobjectId, memberInfo, record.PRobjectId);
                    }
//                          Console.WriteLine("MemberFixup: Main Object({0}): {1}. SubObject({2}): {3}", parent.PRobjectId,
//                                            objectInfo.obj.GetType(), record.PRobjectId, obj.GetType());
                }
                break;
            }
        }
        internal void Fixup(ParseRecord record, ParseRecord parent)
        {
            object prnewObj = record.PRnewObj;

            switch (this.valueFixupEnum)
            {
            case ValueFixupEnum.Array:
                this.arrayObj.SetValue(prnewObj, this.indexMap);
                return;

            case ValueFixupEnum.Header:
            {
                Type typeFromHandle = typeof(Header);
                if (ValueFixup.valueInfo == null)
                {
                    MemberInfo[] member = typeFromHandle.GetMember("Value");
                    if (member.Length != 1)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_HeaderReflection", new object[]
                            {
                                member.Length
                            }));
                    }
                    ValueFixup.valueInfo = member[0];
                }
                FormatterServices.SerializationSetValue(ValueFixup.valueInfo, this.header, prnewObj);
                return;
            }

            case ValueFixupEnum.Member:
            {
                if (this.objectInfo.isSi)
                {
                    this.objectInfo.objectManager.RecordDelayedFixup(parent.PRobjectId, this.memberName, record.PRobjectId);
                    return;
                }
                MemberInfo memberInfo = this.objectInfo.GetMemberInfo(this.memberName);
                if (memberInfo != null)
                {
                    this.objectInfo.objectManager.RecordFixup(parent.PRobjectId, memberInfo, record.PRobjectId);
                }
                return;
            }

            default:
                return;
            }
        }
Exemplo n.º 3
0
 /// <summary>设置字段值。</summary>
 /// <param name="fi">包含有关目标字段的数据的 <see cref="T:System.Reflection.FieldInfo" />。</param>
 /// <param name="target">要更改的字段。</param>
 /// <param name="value">要设置的值。</param>
 /// <PermissionSet>
 ///   <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293" Name="System.Runtime.Serialization.Formatters.Soap" />
 /// </PermissionSet>
 public static void SerializationSetValue(FieldInfo fi, object target, object value)
 {
     if (fi == (FieldInfo)null)
     {
         throw new ArgumentNullException("fi");
     }
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     FormatterServices.SerializationSetValue((MemberInfo)fi, target, value);
 }
Exemplo n.º 4
0
        /// <internalonly/>
        public static void SerializationSetValue(FieldInfo fi, Object target, Object value)
        {
            if (fi == null)
            {
                throw new ArgumentNullException("fi");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            Contract.EndContractBlock();

            FormatterServices.SerializationSetValue(fi, target, value);
        }
Exemplo n.º 5
0
        internal void Fixup(ParseRecord record, ParseRecord parent)
        {
            object obj = record._newObj;

            switch (_valueFixupEnum)
            {
            case ValueFixupEnum.Array:
                _arrayObj.SetValue(obj, _indexMap);
                break;

            case ValueFixupEnum.Header:
                Type type = typeof(Header);
                if (_valueInfo == null)
                {
                    MemberInfo[] valueInfos = type.GetMember("Value");
                    if (valueInfos.Length != 1)
                    {
                        throw new SerializationException(SR.Format(SR.Serialization_HeaderReflection, valueInfos.Length));
                    }
                    _valueInfo = valueInfos[0];
                }
                FormatterServices.SerializationSetValue(_valueInfo, _header, obj);
                break;

            case ValueFixupEnum.Member:
                if (_objectInfo._isSi)
                {
                    _objectInfo._objectManager.RecordDelayedFixup(parent._objectId, _memberName, record._objectId);
                }
                else
                {
                    MemberInfo memberInfo = _objectInfo.GetMemberInfo(_memberName);
                    if (memberInfo != null)
                    {
                        _objectInfo._objectManager.RecordFixup(parent._objectId, memberInfo, record._objectId);
                    }
                }
                break;
            }
        }
Exemplo n.º 6
0
        internal void Fixup(ParseRecord record, ParseRecord parent)
        {
            object obj = record.PRnewObj;

            switch (this.valueFixupEnum)
            {
            case ValueFixupEnum.Array:
                this.arrayObj.SetValue(obj, this.indexMap);
                break;

            case ValueFixupEnum.Header:
                Type type = typeof(Header);
                if (ValueFixup.valueInfo == (MemberInfo)null)
                {
                    MemberInfo[] member = type.GetMember("Value");
                    if (member.Length != 1)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_HeaderReflection", (object)member.Length));
                    }
                    ValueFixup.valueInfo = member[0];
                }
                FormatterServices.SerializationSetValue(ValueFixup.valueInfo, this.header, obj);
                break;

            case ValueFixupEnum.Member:
                if (this.objectInfo.isSi)
                {
                    this.objectInfo.objectManager.RecordDelayedFixup(parent.PRobjectId, this.memberName, record.PRobjectId);
                    break;
                }
                MemberInfo memberInfo = this.objectInfo.GetMemberInfo(this.memberName);
                if (!(memberInfo != (MemberInfo)null))
                {
                    break;
                }
                this.objectInfo.objectManager.RecordFixup(parent.PRobjectId, memberInfo, record.PRobjectId);
                break;
            }
        }