GetMemberInfo() private method

private GetMemberInfo ( String &outMemberNames, Type &outMemberTypes, Object &outMemberData, SoapAttributeInfo &outAttributeInfo ) : void
outMemberNames String
outMemberTypes System.Type
outMemberData Object
outAttributeInfo SoapAttributeInfo
return void
コード例 #1
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes a given object to the stream.
        private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
        {       
            InternalST.Soap( this, "Write 1 Entry objectInfo ",objectInfo,", memberNameInfo ",memberNameInfo,", typeNameInfo ",typeNameInfo);
            memberNameInfo.Dump("Write memberNameInfo");
            typeNameInfo.Dump("Write typeNameInfo");
            Object obj = objectInfo.obj;
            if (obj==null)
                throw new ArgumentNullException("objectInfo.obj", String.Format(SoapUtil.GetResourceString("Serialization_ArgumentNull_Obj"), objectInfo.objectType));

            Type objType = objectInfo.objectType;
            long objectId = objectInfo.objectId;


            InternalST.Soap( this, "Write 1 ",obj," ObjectId ",objectId);

            if (objType == Converter.typeofString)
            {
                // Top level String
                memberNameInfo.NIobjectId = objectId;
                serWriter.WriteObjectString(memberNameInfo, obj.ToString());
            }
            else if (objType == Converter.typeofTimeSpan)
            {
                // Top level TimeSpan
                serWriter.WriteTopPrimitive(memberNameInfo, obj);
            }
            else
            {

                if (objType.IsArray)
                {
                    WriteArray(objectInfo, null, null); 
                }
                else
                {
                    String[] memberNames;
                    Type[] memberTypes;
                    Object[] memberData;
                    SoapAttributeInfo[] memberAttributeInfo;

                    objectInfo.GetMemberInfo(out memberNames, out memberTypes, out memberData, out memberAttributeInfo);

                    // Only Binary needs to transmit types for ISerializable because the binary formatter transmits the types in URT format.
                    // Soap transmits all types as strings, so it is up to the ISerializable object to convert the string back to its URT type
                    if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
                    {
                        InternalST.Soap( this, "Write 1 TransmitOnObject ");
                        memberNameInfo.NItransmitTypeOnObject = true;
                        memberNameInfo.NIisParentTypeOnObject = true;
                        typeNameInfo.NItransmitTypeOnObject = true;
                        typeNameInfo.NIisParentTypeOnObject = true;                                             
                    }

                    WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[memberNames.Length];

                    // Get assembly information
                    // Binary Serializer, assembly names need to be
                    // written before objects are referenced.
                    // GetAssemId here will write out the
                    // assemblyStrings at the right Binary
                    // Serialization object boundary.
                    for (int i=0; i<memberTypes.Length; i++)
                    {
                        Type type = null;
                        if (memberData[i] != null)                        
                            type = GetType(memberData[i]);
                        else
                            type = typeof(Object);

                        InternalPrimitiveTypeE code = Converter.ToCode(type);
                        if ((code == InternalPrimitiveTypeE.Invalid && type != Converter.typeofString) ||
                            ((objectInfo.cache.memberAttributeInfos != null) &&
                             (objectInfo.cache.memberAttributeInfos[i] != null) &&
                             ((objectInfo.cache.memberAttributeInfos[i].IsXmlAttribute()) ||
                              (objectInfo.cache.memberAttributeInfos[i].IsXmlElement()))))
                        {
                            if (memberData[i] != null)
                            {
                                memberObjectInfos[i] =
                                WriteObjectInfo.Serialize
                                (
                                memberData[i],
                                m_surrogates,
                                m_context,
                                serObjectInfoInit,
                                m_formatterConverter,
                                (memberAttributeInfo == null)? null : memberAttributeInfo[i]
                                );                                    
                                memberObjectInfos[i].assemId = GetAssemblyId(memberObjectInfos[i]);
                            }
                            else
                            {
                                memberObjectInfos[i] =
                                WriteObjectInfo.Serialize
                                (
                                memberTypes[i],
                                m_surrogates,
                                m_context,
                                serObjectInfoInit,
                                m_formatterConverter,
                                ((memberAttributeInfo == null) ? null : memberAttributeInfo[i])
                                );
                                memberObjectInfos[i].assemId = GetAssemblyId(memberObjectInfos[i]);
                            }
                        }
                    }

                    Write(objectInfo, memberNameInfo, typeNameInfo, memberNames, memberTypes, memberData, memberObjectInfos);
                }

                InternalST.Soap( this, "Write 1 ",obj," type ",GetType(obj));

                // After first time null members do not have to be written		
                if (!(m_serializedTypeTable.ContainsKey(objType)))
                {
                    InternalST.Soap( this, "Serialize SerializedTypeTable Add ",objType," obj ",obj);           
                    m_serializedTypeTable.Add(objType, objType);
                }
            }

            InternalST.Soap( this, "Write 1 Exit ",obj);        
        }
コード例 #2
0
 private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
 {
     object obj2 = objectInfo.obj;
     if (obj2 == null)
     {
         throw new ArgumentNullException("objectInfo.obj", string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_ArgumentNull_Obj"), new object[] { objectInfo.objectType }));
     }
     if (objectInfo.objectType.IsGenericType)
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SoapNoGenericsSupport"), new object[] { objectInfo.objectType }));
     }
     Type objectType = objectInfo.objectType;
     long objectId = objectInfo.objectId;
     if (objectType == Converter.typeofString)
     {
         memberNameInfo.NIobjectId = objectId;
         this.serWriter.WriteObjectString(memberNameInfo, obj2.ToString());
     }
     else if (objectType == Converter.typeofTimeSpan)
     {
         this.serWriter.WriteTopPrimitive(memberNameInfo, obj2);
     }
     else
     {
         if (objectType.IsArray)
         {
             this.WriteArray(objectInfo, null, null);
         }
         else
         {
             string[] strArray;
             Type[] typeArray;
             object[] objArray;
             SoapAttributeInfo[] infoArray;
             objectInfo.GetMemberInfo(out strArray, out typeArray, out objArray, out infoArray);
             if (this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
             {
                 memberNameInfo.NItransmitTypeOnObject = true;
                 memberNameInfo.NIisParentTypeOnObject = true;
                 typeNameInfo.NItransmitTypeOnObject = true;
                 typeNameInfo.NIisParentTypeOnObject = true;
             }
             WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[strArray.Length];
             for (int i = 0; i < typeArray.Length; i++)
             {
                 if (Nullable.GetUnderlyingType(typeArray[i]) != null)
                 {
                     throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SoapNoGenericsSupport"), new object[] { typeArray[i] }));
                 }
                 Type type = null;
                 if (objArray[i] != null)
                 {
                     type = this.GetType(objArray[i]);
                 }
                 else
                 {
                     type = typeof(object);
                 }
                 if (((Converter.ToCode(type) == InternalPrimitiveTypeE.Invalid) && (type != Converter.typeofString)) || (((objectInfo.cache.memberAttributeInfos != null) && (objectInfo.cache.memberAttributeInfos[i] != null)) && (objectInfo.cache.memberAttributeInfos[i].IsXmlAttribute() || objectInfo.cache.memberAttributeInfos[i].IsXmlElement())))
                 {
                     if (objArray[i] != null)
                     {
                         memberObjectInfos[i] = WriteObjectInfo.Serialize(objArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, (infoArray == null) ? null : infoArray[i], this);
                         memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
                     }
                     else
                     {
                         memberObjectInfos[i] = WriteObjectInfo.Serialize(typeArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, (infoArray == null) ? null : infoArray[i]);
                         memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
                     }
                 }
             }
             this.Write(objectInfo, memberNameInfo, typeNameInfo, strArray, typeArray, objArray, memberObjectInfos);
         }
         if (!this.m_serializedTypeTable.ContainsKey(objectType))
         {
             this.m_serializedTypeTable.Add(objectType, objectType);
         }
     }
 }