コード例 #1
0
        internal static WriteObjectInfo Serialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
        {
            WriteObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit);

            objectInfo.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo, objectWriter);
            return(objectInfo);
        }
コード例 #2
0
        internal static WriteObjectInfo Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit);

            soi.InitSerialize(objectType, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo);
            return(soi);
        }
コード例 #3
0
        private void ArrayNameToDisplayName(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo)
        {
            string nIname = arrayElemTypeNameInfo.NIname;
            int index = nIname.IndexOf('[');
            if (index <= 0)
            {
                if (nIname.Equals("System.Object"))
                {
                    arrayElemTypeNameInfo.NIname = "anyType";
                    arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                }
            }
            else
            {
                string str2 = nIname.Substring(0, index);
                InternalPrimitiveTypeE code = Converter.ToCode(str2);
                string str3 = null;
                bool flag = false;
                switch (code)
                {
                    case InternalPrimitiveTypeE.Invalid:
                        if (!str2.Equals("String") && !str2.Equals("System.String"))
                        {
                            if (str2.Equals("System.Object"))
                            {
                                flag = true;
                                str3 = "anyType";
                                arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                            }
                            else
                            {
                                str3 = str2;
                            }
                            break;
                        }
                        flag = true;
                        str3 = "string";
                        arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrString;
                        break;

                    case InternalPrimitiveTypeE.Char:
                        str3 = str2;
                        arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        break;

                    default:
                    {
                        flag = true;
                        str3 = Converter.ToXmlDataType(code);
                        string typeName = null;
                        arrayElemTypeNameInfo.NInameSpaceEnum = Converter.GetNameSpaceEnum(code, null, objectInfo, out typeName);
                        break;
                    }
                }
                if (flag)
                {
                    arrayElemTypeNameInfo.NIname = str3 + nIname.Substring(index);
                }
            }
        }
コード例 #4
0
        // Write Constructor used for array types or null members
        internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            InternalST.Soap(this, objectInfoId, " Constructor 2 ", objectType);

            this.objectType                = objectType;
            this.context                   = context;
            this.serObjectInfoInit         = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector         = surrogateSelector;
            this.converter                 = converter;

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo   = GetTypeAttributeInfo();
                InitNoMembers();
                return;
            }

            typeAttributeInfo = GetTypeAttributeInfo();

            ISurrogateSelector surrogateSelectorTemp = null;

            if (surrogateSelector != null)
            {
                serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
            }

            if (serializationSurrogate != null)
            {
                isSi = true;
            }
            else if (objectType == Converter.typeofObject)
            {
            }
            else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
            {
                isSi = true;
            }

            if (isSi)
            {
                si    = new SerializationInfo(objectType, converter);
                cache = new SerObjectInfoCache();
                cache.fullTypeName   = si.FullTypeName;
                cache.assemblyString = si.AssemblyName;
            }
            else
            {
                InitMemberInfo();
            }

            InternalST.Soap(this, objectInfoId, " ", objectType, " InitSerialize Exit ", isSi);
        }
コード例 #5
0
 internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
 {
     this.context                   = context;
     this.obj                       = obj;
     this.serObjectInfoInit         = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector         = surrogateSelector;
     this.converter                 = converter;
     if (RemotingServices.IsTransparentProxy(obj))
     {
         this.objectType = Converter.typeofMarshalByRefObject;
     }
     else
     {
         this.objectType = obj.GetType();
     }
     if (this.objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(this.objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo   = this.GetTypeAttributeInfo();
         this.isArray             = true;
         this.InitNoMembers();
     }
     else
     {
         ISurrogateSelector selector;
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         objectWriter.ObjectManager.RegisterObject(obj);
         if ((surrogateSelector != null) && ((this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out selector)) != null))
         {
             this.si = new SerializationInfo(this.objectType, converter);
             if (!this.objectType.IsPrimitive)
             {
                 this.serializationSurrogate.GetObjectData(obj, this.si, context);
             }
             this.InitSiWrite(objectWriter);
         }
         else if (obj is ISerializable)
         {
             if (!this.objectType.IsSerializable)
             {
                 throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"), new object[] { this.objectType.FullName, this.objectType.Module.Assembly.FullName }));
             }
             this.si = new SerializationInfo(this.objectType, converter);
             ((ISerializable)obj).GetObjectData(this.si, context);
             this.InitSiWrite(objectWriter);
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
コード例 #6
0
        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo info = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                info = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                info.InternalInit();
                return(info);
            }
            return(new WriteObjectInfo {
                objectInfoId = serObjectInfoInit.objectInfoIdCount++
            });
        }
コード例 #7
0
 private void InternalInit()
 {
     this.obj                       = null;
     this.objectType                = null;
     this.isSi                      = false;
     this.isNamed                   = false;
     this.isTyped                   = false;
     this.si                        = null;
     this.cache                     = null;
     this.memberData                = null;
     this.isArray                   = false;
     this.objectId                  = 0L;
     this.assemId                   = 0L;
     this.lastPosition              = 0;
     this.typeAttributeInfo         = null;
     this.parentMemberAttributeInfo = null;
     this.arrayElemObjectInfo       = null;
 }
コード例 #8
0
 internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
 {
     this.objectType                = objectType;
     this.context                   = context;
     this.serObjectInfoInit         = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector         = surrogateSelector;
     this.converter                 = converter;
     if (objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo   = this.GetTypeAttributeInfo();
         this.InitNoMembers();
     }
     else
     {
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         ISurrogateSelector selector = null;
         if (surrogateSelector != null)
         {
             this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector);
         }
         if (this.serializationSurrogate != null)
         {
             this.isSi = true;
         }
         else if (!(objectType == Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType))
         {
             this.isSi = true;
         }
         if (this.isSi)
         {
             this.si    = new SerializationInfo(objectType, converter);
             this.cache = new SerObjectInfoCache();
             this.cache.fullTypeName   = this.si.FullTypeName;
             this.cache.assemblyString = this.si.AssemblyName;
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
コード例 #9
0
        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo objectInfo = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                objectInfo.InternalInit();
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
            }
            else
            {
                objectInfo = new WriteObjectInfo();
                objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");
            }

            return(objectInfo);
        }
コード例 #10
0
        private void InternalInit()
        {
            InternalST.Soap(this, objectInfoId, " InternalInit");
            obj        = null;
            objectType = null;
            isSi       = false;
            isNamed    = false;
            isTyped    = false;
            si         = null;
            cache      = null;
            memberData = null;
            isArray    = false;

            // Writing and Parsing information
            objectId = 0;
            assemId  = 0;

            // Added for Soap
            lastPosition              = 0;
            typeAttributeInfo         = null;
            parentMemberAttributeInfo = null;
            arrayElemObjectInfo       = null;
        }
コード例 #11
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes the members of an object
        private void WriteMembers(NameInfo memberNameInfo,
                                  NameInfo memberTypeNameInfo,
                                  Object   memberData,
                                  WriteObjectInfo objectInfo,
                                  NameInfo typeNameInfo,
                                  WriteObjectInfo memberObjectInfo,
                                  bool isAttribute)
        {
            InternalST.Soap( this, "WriteMembers Entry memberType: ",memberTypeNameInfo.NIname," memberName: ",memberNameInfo.NIname," data: ",memberData," objectId: ",objectInfo.objectId, " Container object ",objectInfo.obj, " isAttribute ", isAttribute);
            Type memberType = memberNameInfo.NItype;

            // Types are transmitted for a member as follows:
            // The member is of type object
            // The member object of type is ISerializable and
            //		Soap -  the member is a non-primitive value type, or it is a primitive value type which needs types (TimeSpan, DateTime)
            //				TimeSpan and DateTime are transmitted as UInt64 to keep their precision.
            //      Binary - Types always transmitted.

            if ((memberType == Converter.typeofObject) ||
                (memberType.IsValueType && objectInfo.isSi &&
                 Converter.IsSiTransmitType(memberTypeNameInfo.NIprimitiveTypeEnum)))
            {
                memberTypeNameInfo.NItransmitTypeOnMember  = true;
                memberNameInfo.NItransmitTypeOnMember  = true;              
            }

            if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
            {
                memberTypeNameInfo.NItransmitTypeOnObject  = true;
                memberNameInfo.NItransmitTypeOnObject  = true;
                memberNameInfo.NIisParentTypeOnObject = true;
            }

            if (CheckForNull(objectInfo, memberNameInfo, memberTypeNameInfo, memberData))
            {
                return;
            }

            Object outObj = memberData;
            Type outType = null;

            // If member type does not equal data type, transmit type on object.
            if (memberTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Invalid)
            {
                if (RemotingServices.IsTransparentProxy(outObj))
                    outType = Converter.typeofMarshalByRefObject;
                else
                {
                    outType = GetType(outObj);
                    if (memberType != outType)
                    {
                        memberTypeNameInfo.NItransmitTypeOnMember  = true;
                        memberNameInfo.NItransmitTypeOnMember  = true;                              
                    }
                }
            }

            if (memberType == Converter.typeofObject)
            {
                memberType = GetType(memberData);
                if (memberObjectInfo == null)
                    TypeToNameInfo(memberType, memberTypeNameInfo);
                else
                    TypeToNameInfo(memberObjectInfo, memberTypeNameInfo);                   
                InternalST.Soap( this, "WriteMembers memberType Object, actual memberType ",memberType);                                                                                
            }

            if (memberObjectInfo != null && memberObjectInfo.isArray)
            {
                // Array
                InternalST.Soap( this, "WriteMembers IsArray");

                long arrayId = 0;
                if (!(objectInfo.IsEmbeddedAttribute(memberNameInfo.NIname)|| IsEmbeddedAttribute(memberType)))
                {
                    arrayId = Schedule(outObj, outType, memberObjectInfo);
                }
                if (arrayId > 0)
                {
                    // Array as object
                    InternalST.Soap( this, "WriteMembers Schedule 3");
                    memberNameInfo.NIobjectId = arrayId;
                    WriteObjectRef(memberNameInfo, arrayId); 
                }
                else
                {
                    // Nested Array
                    serWriter.WriteMemberNested(memberNameInfo);

                    memberObjectInfo.objectId = arrayId;
                    memberNameInfo.NIobjectId = arrayId;
                    memberNameInfo.NIisNestedObject = true;
                    WriteArray(memberObjectInfo, memberNameInfo, memberObjectInfo);
                }
                InternalST.Soap( this, "WriteMembers Array Exit ");
                return;
            }

            if (!WriteKnownValueClass(memberNameInfo, memberTypeNameInfo, memberData, isAttribute))
            {
                InternalST.Soap( this, "WriteMembers Object ",memberData);

                // In soap an enum is written out as a string
                if (memberTypeNameInfo.NItype.IsEnum)
                    WriteEnum(memberNameInfo, memberTypeNameInfo, memberData, isAttribute);
                else
                {

                    if (isAttribute)
                    {
                        // XmlAttribute must be a primitive type or string
                        throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_NonPrimitive_XmlAttribute"), memberNameInfo.NIname));                                  
                    }

                    // Value or NO_ID, need to explicitly check for IsValue because a top level
                    // value class has an objectId of 1
                    if ((memberType.IsValueType) || objectInfo.IsEmbeddedAttribute(memberNameInfo.NIname) || IsEmbeddedAttribute(outType))
                    {
                        InternalST.Soap( this, "WriteMembers Value Type or NO_ID parameter");
                        serWriter.WriteMemberNested(memberNameInfo);

                        memberObjectInfo.objectId = -1;
                        NameInfo newTypeNameInfo = TypeToNameInfo(memberObjectInfo);
                        newTypeNameInfo.NIobjectId = -1;
                        memberNameInfo.NIisNestedObject = true;
                        if (objectInfo.isSi)
                        {
                            memberTypeNameInfo.NItransmitTypeOnMember  = true;
                            memberNameInfo.NItransmitTypeOnMember  = true;                              
                        }
                        Write( memberObjectInfo, memberNameInfo, newTypeNameInfo);
                        PutNameInfo(newTypeNameInfo);
                        memberObjectInfo.ObjectEnd();
                    }
                    else
                    {
                        InternalST.Soap( this, "WriteMembers Schedule 4");
                        long memberObjectId = 0;
                        memberObjectId = Schedule(outObj, outType, memberObjectInfo);

                        if (memberObjectId < 0)
                        {
                            // Nested object
                            InternalST.Soap( this, "WriteMembers Nesting");
                            serWriter.WriteMemberNested(memberNameInfo);

                            memberObjectInfo.objectId = -1;
                            NameInfo newTypeNameInfo = TypeToNameInfo(memberObjectInfo);
                            newTypeNameInfo.NIobjectId = -1;
                            memberNameInfo.NIisNestedObject = true;     
                            Write(memberObjectInfo, memberNameInfo, newTypeNameInfo);
                            PutNameInfo(newTypeNameInfo);
                            memberObjectInfo.ObjectEnd();
                        }
                        else
                        {
                            // Object reference
                            memberNameInfo.NIobjectId = memberObjectId;
                            WriteObjectRef(memberNameInfo, memberObjectId); 
                        }
                    }
                }
            }

            InternalST.Soap( this, "WriteMembers Exit ");
        }
コード例 #12
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes a given object to the stream.
        private void Write(WriteObjectInfo objectInfo,         
                           NameInfo memberNameInfo,          
                           NameInfo typeNameInfo,            
                           String[] memberNames,             
                           Type[] memberTypes,               
                           Object[] memberData,              
                           WriteObjectInfo[] memberObjectInfos)
        {
            InternalST.Soap( this, "Write 2 Entry obj ",objectInfo.obj,". objectId ",objectInfo.objectId,", objType ",typeNameInfo.NIname,", memberName ",memberNameInfo.NIname,", memberType ",typeNameInfo.NIname,", isMustUnderstand ",memberNameInfo.NIisMustUnderstand);

            int numItems = memberNames.Length;
            NameInfo topNameInfo = null;

            // Process members which will be written out as Soap attributes first
            if (objectInfo.cache.memberAttributeInfos != null)
            {
                InternalST.Soap( this, "Write Attribute Members");
                for (int i=0; i<objectInfo.cache.memberAttributeInfos.Length; i++)
                {
                    InternalST.Soap( this, "Write Attribute Members name ", memberNames[i]);                    
                    if ((objectInfo.cache.memberAttributeInfos[i] != null) &&
                        (objectInfo.cache.memberAttributeInfos[i].IsXmlAttribute()))
                        WriteMemberSetup(objectInfo, memberNameInfo, typeNameInfo, memberNames[i], memberTypes[i], memberData[i], memberObjectInfos[i], true);
                }
            }


            if (memberNameInfo != null)
            {
                InternalST.Soap( this, "Write 2 ObjectBegin, memberName ",memberNameInfo.NIname);
                memberNameInfo.NIobjectId = objectInfo.objectId;
                serWriter.WriteObject(memberNameInfo, typeNameInfo, numItems, memberNames, memberTypes, memberObjectInfos);
            }
            else if ((objectInfo.objectId == topId) && (topName != null))
            {
                InternalST.Soap( this, "Write 2 ObjectBegin, topId method name ",topName);
                topNameInfo = MemberToNameInfo(topName);
                topNameInfo.NIobjectId = objectInfo.objectId;
                serWriter.WriteObject(topNameInfo, typeNameInfo, numItems, memberNames, memberTypes, memberObjectInfos);
            }
            else
            {
                if (objectInfo.objectType != Converter.typeofString)
                {
                    InternalST.Soap( this, "Write 2 ObjectBegin, default ", typeNameInfo.NIname);
                    typeNameInfo.NIobjectId = objectInfo.objectId;
                    serWriter.WriteObject(typeNameInfo, null, numItems, memberNames, memberTypes, memberObjectInfos);
                }
            }

            if (memberNameInfo.NIisParentTypeOnObject)
            {
                memberNameInfo.NItransmitTypeOnObject = true;
                memberNameInfo.NIisParentTypeOnObject = false;
            }
            else
                memberNameInfo.NItransmitTypeOnObject = false;


            // Write members
            for (int i=0; i<numItems; i++)
            {
                if ((objectInfo.cache.memberAttributeInfos == null) ||
                    (objectInfo.cache.memberAttributeInfos[i] == null) ||
                    (!(objectInfo.cache.memberAttributeInfos[i].IsXmlAttribute())))
                    WriteMemberSetup(objectInfo, memberNameInfo, typeNameInfo, memberNames[i], memberTypes[i], memberData[i], memberObjectInfos[i], false);
            }

            if (memberNameInfo != null)
            {
                memberNameInfo.NIobjectId = objectInfo.objectId;
                serWriter.WriteObjectEnd(memberNameInfo, typeNameInfo);
            }
            else if ((objectInfo.objectId == topId) && (topName != null))
            {
                serWriter.WriteObjectEnd(topNameInfo, typeNameInfo);
                PutNameInfo(topNameInfo);
            }
            else
            {
                if (objectInfo.objectType != Converter.typeofString)
                {
                    String objectName = objectInfo.GetTypeFullName();
                    serWriter.WriteObjectEnd(typeNameInfo, typeNameInfo);                       
                }
            }

            InternalST.Soap( this, "Write 2 Exit");
        }
コード例 #13
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        private void ProcessHeaders(long headerId)
        {
            long objectId;
            Object obj;

            // XML Serializer

            serWriter.WriteHeader((int)headerId, headers.Length);

            for (int i=0; i<headers.Length; i++)
            {
                Type headerValueType = null;
                if (headers[i].Value != null)
                    headerValueType = GetType(headers[i].Value);
                if ((headerValueType != null) && (headerValueType == Converter.typeofString))
                {
                    NameInfo nameInfo = GetNameInfo();
                    nameInfo.NInameSpaceEnum = InternalNameSpaceE.UserNameSpace;
                    nameInfo.NIname = headers[i].Name;
                    nameInfo.NIisMustUnderstand = headers[i].MustUnderstand;
                    nameInfo.NIobjectId = -1;

                    // Header will need to add a name space field which will if it doesn't the following
                    // is the default name space
                    HeaderNamespace(headers[i], nameInfo);

                    serWriter.WriteHeaderString(nameInfo, headers[i].Value.ToString());

                    PutNameInfo(nameInfo);
                }
                else if (headers[i].Name.Equals("__MethodSignature"))
                {
                    InternalST.Soap( this, "Serialize Write Header __MethodSignature ");                        
                    // Process message signature
                    if (!(headers[i].Value is Type[]))
                        throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_MethodSignature"), headerValueType));
                    // Replace type array with an array of TypeToNameInfo's
                    Type[] types = (Type[])headers[i].Value;
                    NameInfo[] typeToNameInfos = new NameInfo[types.Length];
                    WriteObjectInfo[] objectInfos = new WriteObjectInfo[types.Length];
                    for (int j=0; j< types.Length; j++)
                    {
                        objectInfos[j] = WriteObjectInfo.Serialize(types[j], m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                        objectInfos[j].objectId = -1;
                        objectInfos[j].assemId = GetAssemblyId(objectInfos[j]);                             
                        typeToNameInfos[j] = TypeToNameInfo(objectInfos[j]);
                    }

                    // Create MemberNameInfo 
                    NameInfo memberNameInfo = MemberToNameInfo(headers[i].Name);
                    memberNameInfo.NIisMustUnderstand = headers[i].MustUnderstand;
                    memberNameInfo.NItransmitTypeOnMember = true;
                    memberNameInfo.NIisNestedObject = true;
                    memberNameInfo.NIisHeader = true;
                    HeaderNamespace(headers[i], memberNameInfo);

                    serWriter.WriteHeaderMethodSignature(memberNameInfo, typeToNameInfos);

                    for (int j=0; j<types.Length; j++)
                    {
                        PutNameInfo(typeToNameInfos[j]);
                        objectInfos[j].ObjectEnd();
                    }
                    PutNameInfo(memberNameInfo);
                }
                else
                {
                    InternalPrimitiveTypeE code = InternalPrimitiveTypeE.Invalid;
                    long valueId;
                    if (headerValueType != null)
                        code = Converter.ToCode(headerValueType);

                    if ((headerValueType != null) && (code == InternalPrimitiveTypeE.Invalid))
                    {
                        // Object reference
                        InternalST.Soap( this, "Serialize Schedule 2");
                        valueId = Schedule(headers[i].Value, headerValueType);
                        if (valueId == -1)
                        {
                            WriteObjectInfo objectInfo = WriteObjectInfo.Serialize(headers[i].Value, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                            objectInfo.objectId = -1;
                            objectInfo.assemId = GetAssemblyId(objectInfo);                             
                            NameInfo typeNameInfo = TypeToNameInfo(objectInfo);
                            NameInfo memberNameInfo = MemberToNameInfo(headers[i].Name);
                            memberNameInfo.NIisMustUnderstand = headers[i].MustUnderstand;
                            memberNameInfo.NItransmitTypeOnMember = true;
                            memberNameInfo.NIisNestedObject = true;
                            memberNameInfo.NIisHeader = true;

                            HeaderNamespace(headers[i], memberNameInfo);

                            Write(objectInfo, memberNameInfo, typeNameInfo);
                            PutNameInfo(typeNameInfo);
                            PutNameInfo(memberNameInfo);
                            objectInfo.ObjectEnd();
                        }
                        InternalST.Soap( this, "Serialize Write Header Object Reference ");
                        NameInfo refNameInfo = MemberToNameInfo(headers[i].Name);
                        refNameInfo.NIisMustUnderstand = headers[i].MustUnderstand;
                        refNameInfo.NIobjectId = valueId;
                        refNameInfo.NItransmitTypeOnMember = true;
                        refNameInfo.NIisNestedObject = true;                                                                                    
                        HeaderNamespace(headers[i], refNameInfo);
                        serWriter.WriteHeaderObjectRef(refNameInfo);
                        PutNameInfo(refNameInfo);
                    }
                    else
                    {
                        // Primitive type or null					
                        InternalST.Soap( this, "Serialize Write Header primitive type ");
                        NameInfo nameInfo = GetNameInfo();
                        nameInfo.NInameSpaceEnum = InternalNameSpaceE.UserNameSpace;
                        nameInfo.NIname = headers[i].Name;
                        nameInfo.NIisMustUnderstand = headers[i].MustUnderstand;
                        nameInfo.NIprimitiveTypeEnum = code;

                        // Header will need to add a name space field which will if it doesn't the following
                        // is the default name space
                        HeaderNamespace(headers[i], nameInfo);

                        NameInfo typeNameInfo = null;
                        if (headerValueType != null)
                        {
                            typeNameInfo = TypeToNameInfo(headerValueType);
                            typeNameInfo.NItransmitTypeOnMember = true;
                        }
                        serWriter.WriteHeaderEntry(nameInfo, typeNameInfo, headers[i].Value);
                        PutNameInfo(nameInfo);
                        if (headerValueType != null)
                            PutNameInfo(typeNameInfo);
                    }
                }
            }

            serWriter.WriteHeaderArrayEnd();

            // Serialize headers ahead of top graph
            while ((obj = GetNext(out objectId))!=null)
            {
                WriteObjectInfo objectInfo = null;

                // GetNext will return either an object or a WriteObjectInfo. 
                // A WriteObjectInfo is returned if this object was member of another object
                if (obj is WriteObjectInfo)
                {
                    InternalST.Soap( this, "Serialize GetNext recognizes WriteObjectInfo");
                    objectInfo = (WriteObjectInfo)obj;
                }
                else
                {
                    objectInfo = WriteObjectInfo.Serialize(obj, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                    objectInfo.assemId = GetAssemblyId(objectInfo);
                }


                objectInfo.objectId = objectId;
                NameInfo typeNameInfo = TypeToNameInfo(objectInfo);
                Write(objectInfo, typeNameInfo, typeNameInfo);
                PutNameInfo(typeNameInfo);
                objectInfo.ObjectEnd();
            }

            serWriter.WriteHeaderSectionEnd();
        }
コード例 #14
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        private void ArrayNameToDisplayName(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo)
        {

            InternalST.Soap( this, "ArrayNameToDisplayName Entry ",arrayElemTypeNameInfo.NIname);           

            String arrayElemTypeName = arrayElemTypeNameInfo.NIname;
            //String arrayElemTypeName = objectInfo.GetTypeFullName();;    
            InternalST.Soap( this, "ArrayNameToDisplayName Entry ",arrayElemTypeNameInfo.NIname, " Type full name ", arrayElemTypeName);            
            int arrayIndex = arrayElemTypeName.IndexOf('[');
            if (arrayIndex > 0)
            {
                String elemBaseTypeString = arrayElemTypeName.Substring(0, arrayIndex);
                InternalPrimitiveTypeE code = Converter.ToCode(elemBaseTypeString);
                String convertedType = null;
                bool isConverted = false;
                if (code != InternalPrimitiveTypeE.Invalid)
                {
                    if (code == InternalPrimitiveTypeE.Char)
                    {
                        convertedType = elemBaseTypeString;
                        arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.UrtSystem;
                    }
                    else
                    {
                        isConverted = true;
                        convertedType = Converter.ToXmlDataType(code);
                        String typeName = null;                 
                        arrayElemTypeNameInfo.NInameSpaceEnum = Converter.GetNameSpaceEnum(code, null, objectInfo, out typeName); 
                    }
                }
                else
                {
                    InternalST.Soap( this, "ArrayNameToDisplayName elemBaseTypeString ",elemBaseTypeString);                                
                    if ((elemBaseTypeString.Equals("String")) || (elemBaseTypeString.Equals("System.String")))
                    {
                        isConverted = true;
                        convertedType = "string";
                        arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrString;
                    }
                    else if (elemBaseTypeString.Equals("System.Object"))
                    {
                        isConverted = true;
                        convertedType = "anyType";
                        arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                    }
                    else
                    {
                        convertedType = elemBaseTypeString;
                    }
                }

                if (isConverted)
                {
                    arrayElemTypeNameInfo.NIname = convertedType+arrayElemTypeName.Substring(arrayIndex);
                }
            }
            else if (arrayElemTypeName.Equals("System.Object"))
            {
                arrayElemTypeNameInfo.NIname = "anyType";
                arrayElemTypeNameInfo.NInameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
            }

            InternalST.Soap( this, "ArrayNameToDisplayName Exit ",arrayElemTypeNameInfo.NIname);                        
        }
コード例 #15
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
 private NameInfo TypeToNameInfo(WriteObjectInfo objectInfo, InternalPrimitiveTypeE code)
 {
     return TypeToNameInfo(objectInfo.objectType, objectInfo, code, null);
 }
コード例 #16
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Transforms a type to the serialized string form. URT Primitive types are converted to XMLData Types
        private NameInfo TypeToNameInfo(Type type, WriteObjectInfo objectInfo, InternalPrimitiveTypeE code, NameInfo nameInfo)
        {
            InternalST.Soap( this, "TypeToNameInfo Entry type ",type,", objectInfo ",objectInfo,", code ", ((Enum)code).ToString());
            if (nameInfo == null)
                nameInfo = GetNameInfo();
            else
                nameInfo.Init();

            nameInfo.NIisSealed = type.IsSealed;

            String typeName = null;
            nameInfo.NInameSpaceEnum = Converter.GetNameSpaceEnum(code, type, objectInfo, out typeName);
            nameInfo.NIprimitiveTypeEnum = code;
            nameInfo.NItype = type;
            nameInfo.NIname = typeName;
            if (objectInfo != null)
            {
                nameInfo.NIattributeInfo = objectInfo.typeAttributeInfo;                    
                nameInfo.NIassemId = objectInfo.assemId;
            }

            switch (nameInfo.NInameSpaceEnum)
            {
                case InternalNameSpaceE.XdrPrimitive:
                    break;
                case InternalNameSpaceE.XdrString:
                    nameInfo.NIname = "string";
                    break;
                case InternalNameSpaceE.UrtSystem:
                    break;
                case InternalNameSpaceE.UrtUser:
                    //if (type.FullName.StartsWith("System."))
                    if (type.Module.Assembly == Converter.urtAssembly)
                    {
                        // The type name could be an ISerializable
                        // But the type returned (typeName) could be a fake
                        // type
                    }
                    else
                    {
                        if (objectInfo == null)
                        {
                            InternalST.Soap( this, "TypeToNameInfo ObjectInfo is null 2 ",type);
                        }
                    }
                    break;
            }

            InternalST.Soap( this, "TypeToNameInfo Exit ",type, " typeName "+nameInfo.NIname);
            return nameInfo;            
        }
コード例 #17
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        private long Schedule(Object obj, Type type, WriteObjectInfo objectInfo)
        {
            InternalST.Soap( this, "Schedule Entry ",((obj == null)?"null":obj));

            bool isNew;
            long id;

            if (obj==null)
            {
                InternalST.Soap(this, "Schedule Obj Null, id = 0 ");
                return 0;
            }

            id = InternalGetId(obj, type, out isNew);           

            if (isNew)
            {
                if (objectInfo == null)
                    m_objectQueue.Enqueue(obj);
                else
                    m_objectQueue.Enqueue(objectInfo);
            }

            InternalST.Soap( this, "Schedule Exit, id: ",id," isNew: ",isNew);      
            return id;
        }
コード例 #18
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes out an array element
        private void WriteArrayMember(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, Object data)
        {
            InternalST.Soap( this, "WriteArrayMember ",data," baseArrayName ",arrayElemTypeNameInfo.NIname);

            arrayElemTypeNameInfo.NIisArrayItem = true;

            if (CheckForNull(objectInfo, arrayElemTypeNameInfo, arrayElemTypeNameInfo, data))
                return;

            NameInfo actualTypeInfo = null;

            Type dataType = null;

            bool isObjectOnMember = false;

            if (arrayElemTypeNameInfo.NItransmitTypeOnMember)
                isObjectOnMember = true;

            if (!isObjectOnMember && !arrayElemTypeNameInfo.NIisSealed)
            {
                dataType = GetType(data);
                if (arrayElemTypeNameInfo.NItype != dataType)
                    isObjectOnMember = true;
            }

            if (isObjectOnMember)
            {
                // Object array, need type of member
                if (dataType == null)
                    dataType = GetType(data);
                actualTypeInfo = TypeToNameInfo(dataType);
                actualTypeInfo.NItransmitTypeOnMember = true;
                actualTypeInfo.NIobjectId = arrayElemTypeNameInfo.NIobjectId;
                actualTypeInfo.NIassemId = arrayElemTypeNameInfo.NIassemId;
                actualTypeInfo.NIisArrayItem = true;
                actualTypeInfo.NIitemName = arrayElemTypeNameInfo.NIitemName;
            }
            else
            {
                actualTypeInfo = arrayElemTypeNameInfo;
                actualTypeInfo.NIisArrayItem = true;
            }

            if (!WriteKnownValueClass(arrayElemTypeNameInfo, actualTypeInfo, data, false))
            {
                Object obj = data;

                if (actualTypeInfo.NItype.IsEnum)
                {
                    WriteObjectInfo newObjectInfo = WriteObjectInfo.Serialize(obj, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                    actualTypeInfo.NIassemId = GetAssemblyId(newObjectInfo);
                    WriteEnum(arrayElemTypeNameInfo, actualTypeInfo, data, false);
                }
                else
                {
                    long arrayId = Schedule(obj, actualTypeInfo.NItype);
                    arrayElemTypeNameInfo.NIobjectId = arrayId;
                    actualTypeInfo.NIobjectId = arrayId;
                    if (arrayId < 1)
                    {
                        WriteObjectInfo newObjectInfo = WriteObjectInfo.Serialize(obj, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                        newObjectInfo.objectId = arrayId;
                        newObjectInfo.assemId = GetAssemblyId(newObjectInfo);

                        InternalST.Soap( this, "WriteArrayMembers nested");
                        if (dataType == null)
                            dataType = GetType(data);
                        if (data!=null && dataType.IsArray)
                        {
                            WriteArray(newObjectInfo, actualTypeInfo, null);
                        }
                        else
                        {
                            actualTypeInfo.NIisNestedObject = true;
                            NameInfo typeNameInfo = TypeToNameInfo(newObjectInfo);
                            typeNameInfo.NIobjectId = arrayId;
                            newObjectInfo.objectId = arrayId;
                            Write(newObjectInfo, actualTypeInfo, typeNameInfo);
                        }

                        newObjectInfo.ObjectEnd();
                    }
                    else
                        serWriter.WriteItemObjectRef(arrayElemTypeNameInfo, (int)arrayId);
                }
            }
            if (arrayElemTypeNameInfo.NItransmitTypeOnMember)
                PutNameInfo(actualTypeInfo);
        }
コード例 #19
0
        internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
        {
            this.attrList.Clear();
            if (memberNameInfo.NIobjectId == this.topId)
            {
                this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
            }
            if (arrayNameInfo.NIobjectId > 1L)
            {
                this.attrList.Put("id", this.IdToString((int)arrayNameInfo.NIobjectId));
            }
            arrayElemTypeNameInfo.NIitemName = "SOAP-ENC:Array";
            this.isUsedEnc = true;
            this.attrList.Put("SOAP-ENC:arrayType", this.TypeArrayNameTagResolver(memberNameInfo, arrayNameInfo, true));
            if (lowerBound != 0)
            {
                this.attrList.Put("SOAP-ENC:offset", "[" + lowerBound + "]");
            }
            string name = this.MemberElementName(memberNameInfo, null);

            this.NamespaceAttribute();
            this.Write(InternalElementTypeE.ObjectBegin, name, this.attrList, null, false, false);
        }
コード例 #20
0
 internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
 {
     InternalNameSpaceE none = InternalNameSpaceE.None;
     typeName = null;
     if (code != InternalPrimitiveTypeE.Invalid)
     {
         if (code == InternalPrimitiveTypeE.Char)
         {
             none = InternalNameSpaceE.UrtSystem;
             typeName = "System.Char";
         }
         else
         {
             none = InternalNameSpaceE.XdrPrimitive;
             typeName = ToXmlDataType(code);
         }
     }
     if ((none == InternalNameSpaceE.None) && (type != null))
     {
         if (type == typeofString)
         {
             none = InternalNameSpaceE.XdrString;
         }
         else if (objectInfo == null)
         {
             typeName = type.FullName;
             if (type.Module.Assembly == urtAssembly)
             {
                 none = InternalNameSpaceE.UrtSystem;
             }
             else
             {
                 none = InternalNameSpaceE.UrtUser;
             }
         }
         else
         {
             typeName = objectInfo.GetTypeFullName();
             if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
             {
                 none = InternalNameSpaceE.UrtSystem;
             }
             else
             {
                 none = InternalNameSpaceE.UrtUser;
             }
         }
     }
     if (objectInfo != null)
     {
         if (!objectInfo.isSi && ((objectInfo.IsAttributeNameSpace() || objectInfo.IsCustomXmlAttribute()) || objectInfo.IsCustomXmlElement()))
         {
             return InternalNameSpaceE.Interop;
         }
         if (objectInfo.IsCallElement())
         {
             none = InternalNameSpaceE.CallElement;
         }
     }
     return none;
 }
コード例 #21
0
ファイル: soapobjectinfo.cs プロジェクト: ArildF/masters
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
     //InternalST.Soap( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");							
 }
コード例 #22
0
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
     //InternalST.Soap( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");
 }
コード例 #23
0
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
 }
コード例 #24
0
        // Write constructor
        internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
        {
            InternalST.Soap(this, objectInfoId, " Constructor 1 ", obj);
            this.context                   = context;
            this.obj                       = obj;
            this.serObjectInfoInit         = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector         = surrogateSelector;
            this.converter                 = converter;
            ISurrogateSelector surrogateSelectorTemp;

            if (RemotingServices.IsTransparentProxy(obj))
            {
                objectType = Converter.typeofMarshalByRefObject;
            }
            else
            {
                objectType = obj.GetType();
            }

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo   = GetTypeAttributeInfo();
                isArray             = true;
                InitNoMembers();
                return;
            }

            InternalST.Soap(this, objectInfoId, " Constructor 1 trace 2");

            typeAttributeInfo = GetTypeAttributeInfo();

            objectWriter.ObjectManager.RegisterObject(obj);
            if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
            {
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 3");
                si = new SerializationInfo(objectType, converter);
                if (!objectType.IsPrimitive)
                {
                    serializationSurrogate.GetObjectData(obj, si, context);
                }
                InitSiWrite(objectWriter);
            }
            else if (obj is ISerializable)
            {
                if (!objectType.IsSerializable)
                {
                    throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"),
                                                                   objectType.FullName, objectType.Module.Assembly.FullName));
                }
                si = new SerializationInfo(objectType, converter);
                ((ISerializable)obj).GetObjectData(si, context);
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 4 ISerializable " + objectType);
                InitSiWrite(objectWriter);
            }
            else
            {
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 5");
                InitMemberInfo();
            }
        }
コード例 #25
0
ファイル: soapobjectinfo.cs プロジェクト: ArildF/masters
        private void InternalInit()
        {
            InternalST.Soap( this, objectInfoId," InternalInit");                                                                                        
            obj = null;
            objectType = null;
            isSi = false;
            isNamed = false;
            isTyped = false;
            si = null;
            cache = null;
            memberData = null;
            isArray = false;

            // Writing and Parsing information
            objectId = 0;
            assemId = 0;

            // Added for Soap
            lastPosition = 0;
            typeAttributeInfo = null;
            parentMemberAttributeInfo = null;
            arrayElemObjectInfo = null;
        }
コード例 #26
0
 private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, string[] memberNames, Type[] memberTypes, object[] memberData, WriteObjectInfo[] memberObjectInfos)
 {
     int length = memberNames.Length;
     NameInfo nameInfo = null;
     if (objectInfo.cache.memberAttributeInfos != null)
     {
         for (int j = 0; j < objectInfo.cache.memberAttributeInfos.Length; j++)
         {
             if ((objectInfo.cache.memberAttributeInfos[j] != null) && objectInfo.cache.memberAttributeInfos[j].IsXmlAttribute())
             {
                 this.WriteMemberSetup(objectInfo, memberNameInfo, typeNameInfo, memberNames[j], memberTypes[j], memberData[j], memberObjectInfos[j], true);
             }
         }
     }
     if (memberNameInfo != null)
     {
         memberNameInfo.NIobjectId = objectInfo.objectId;
         this.serWriter.WriteObject(memberNameInfo, typeNameInfo, length, memberNames, memberTypes, memberObjectInfos);
     }
     else if ((objectInfo.objectId == this.topId) && (this.topName != null))
     {
         nameInfo = this.MemberToNameInfo(this.topName);
         nameInfo.NIobjectId = objectInfo.objectId;
         this.serWriter.WriteObject(nameInfo, typeNameInfo, length, memberNames, memberTypes, memberObjectInfos);
     }
     else if (objectInfo.objectType != Converter.typeofString)
     {
         typeNameInfo.NIobjectId = objectInfo.objectId;
         this.serWriter.WriteObject(typeNameInfo, null, length, memberNames, memberTypes, memberObjectInfos);
     }
     if (memberNameInfo.NIisParentTypeOnObject)
     {
         memberNameInfo.NItransmitTypeOnObject = true;
         memberNameInfo.NIisParentTypeOnObject = false;
     }
     else
     {
         memberNameInfo.NItransmitTypeOnObject = false;
     }
     for (int i = 0; i < length; i++)
     {
         if (((objectInfo.cache.memberAttributeInfos == null) || (objectInfo.cache.memberAttributeInfos[i] == null)) || !objectInfo.cache.memberAttributeInfos[i].IsXmlAttribute())
         {
             this.WriteMemberSetup(objectInfo, memberNameInfo, typeNameInfo, memberNames[i], memberTypes[i], memberData[i], memberObjectInfos[i], false);
         }
     }
     if (memberNameInfo != null)
     {
         memberNameInfo.NIobjectId = objectInfo.objectId;
         this.serWriter.WriteObjectEnd(memberNameInfo, typeNameInfo);
     }
     else if ((objectInfo.objectId == this.topId) && (this.topName != null))
     {
         this.serWriter.WriteObjectEnd(nameInfo, typeNameInfo);
         this.PutNameInfo(nameInfo);
     }
     else if (objectInfo.objectType != Converter.typeofString)
     {
         objectInfo.GetTypeFullName();
         this.serWriter.WriteObjectEnd(typeNameInfo, typeNameInfo);
     }
 }
コード例 #27
0
        internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
        {
            this.sbOffset.Length = 0;
            this.sbOffset.Append("[");
            bool flag = true;

            for (int i = 0; i < rank; i++)
            {
                if (lowerBoundA[i] != 0)
                {
                    flag = false;
                }
                if (i > 0)
                {
                    this.sbOffset.Append(",");
                }
                this.sbOffset.Append(lowerBoundA[i]);
            }
            this.sbOffset.Append("]");
            this.attrList.Clear();
            if (memberNameInfo.NIobjectId == this.topId)
            {
                this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
            }
            if (arrayNameInfo.NIobjectId > 1L)
            {
                this.attrList.Put("id", this.IdToString((int)arrayNameInfo.NIobjectId));
            }
            arrayElemTypeNameInfo.NIitemName = this.NameTagResolver(arrayElemTypeNameInfo, true);
            this.attrList.Put("SOAP-ENC:arrayType", this.TypeArrayNameTagResolver(memberNameInfo, arrayNameInfo, true));
            this.isUsedEnc = true;
            if (!flag)
            {
                this.attrList.Put("SOAP-ENC:offset", this.sbOffset.ToString());
            }
            string name = this.MemberElementName(memberNameInfo, null);

            this.NamespaceAttribute();
            this.Write(InternalElementTypeE.ObjectBegin, name, this.attrList, null, false, false);
        }
コード例 #28
0
        private void WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)
        {
            InternalArrayTypeE jagged;
            bool flag2;
            bool flag = false;
            if (memberNameInfo == null)
            {
                memberNameInfo = this.TypeToNameInfo(objectInfo);
                memberNameInfo.NIisTopLevelObject = true;
                flag = true;
            }
            memberNameInfo.NIisArray = true;
            long objectId = objectInfo.objectId;
            memberNameInfo.NIobjectId = objectInfo.objectId;
            Array array = (Array) objectInfo.obj;
            Type elementType = objectInfo.objectType.GetElementType();
            if (Nullable.GetUnderlyingType(elementType) != null)
            {
                throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SoapNoGenericsSupport"), new object[] { elementType }));
            }
            WriteObjectInfo info = WriteObjectInfo.Serialize(elementType, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, (memberObjectInfo == null) ? null : memberObjectInfo.typeAttributeInfo);
            info.assemId = this.GetAssemblyId(info);
            NameInfo arrayElemTypeNameInfo = null;
            NameInfo arrayNameInfo = this.ArrayTypeToNameInfo(objectInfo, out arrayElemTypeNameInfo);
            arrayNameInfo.NIobjectId = objectId;
            arrayNameInfo.NIisArray = true;
            arrayElemTypeNameInfo.NIobjectId = objectId;
            arrayElemTypeNameInfo.NItransmitTypeOnMember = memberNameInfo.NItransmitTypeOnMember;
            arrayElemTypeNameInfo.NItransmitTypeOnObject = memberNameInfo.NItransmitTypeOnObject;
            arrayElemTypeNameInfo.NIisParentTypeOnObject = memberNameInfo.NIisParentTypeOnObject;
            int rank = array.Rank;
            int[] lengthA = new int[rank];
            int[] lowerBoundA = new int[rank];
            int[] numArray3 = new int[rank];
            for (int i = 0; i < rank; i++)
            {
                lengthA[i] = array.GetLength(i);
                lowerBoundA[i] = array.GetLowerBound(i);
                numArray3[i] = array.GetUpperBound(i);
            }
            if (elementType.IsArray)
            {
                if (rank == 1)
                {
                    jagged = InternalArrayTypeE.Jagged;
                }
                else
                {
                    jagged = InternalArrayTypeE.Rectangular;
                }
            }
            else if (rank == 1)
            {
                jagged = InternalArrayTypeE.Single;
            }
            else
            {
                jagged = InternalArrayTypeE.Rectangular;
            }
            if (((elementType == Converter.typeofByte) && (rank == 1)) && (lowerBoundA[0] == 0))
            {
                this.serWriter.WriteObjectByteArray(memberNameInfo, arrayNameInfo, info, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], (byte[]) array);
                return;
            }
            if (elementType == Converter.typeofObject)
            {
                memberNameInfo.NItransmitTypeOnMember = true;
                arrayElemTypeNameInfo.NItransmitTypeOnMember = true;
            }
            if (this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
            {
                memberNameInfo.NItransmitTypeOnObject = true;
                arrayElemTypeNameInfo.NItransmitTypeOnObject = true;
            }
            switch (jagged)
            {
                case InternalArrayTypeE.Single:
                    arrayNameInfo.NIname = string.Concat(new object[] { arrayElemTypeNameInfo.NIname, "[", lengthA[0], "]" });
                    this.serWriter.WriteSingleArray(memberNameInfo, arrayNameInfo, info, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], array);
                    if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBoundA[0] == 0))
                    {
                        arrayElemTypeNameInfo.NIobjectId = 0L;
                        if (this.primitiveArray == null)
                        {
                            this.primitiveArray = new PrimitiveArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum, array);
                        }
                        else
                        {
                            this.primitiveArray.Init(arrayElemTypeNameInfo.NIprimitiveTypeEnum, array);
                        }
                        int num4 = numArray3[0] + 1;
                        for (int j = lowerBoundA[0]; j < num4; j++)
                        {
                            this.serWriter.WriteItemString(arrayElemTypeNameInfo, arrayElemTypeNameInfo, this.primitiveArray.GetValue(j));
                        }
                    }
                    else
                    {
                        object[] objArray = null;
                        if (!elementType.IsValueType)
                        {
                            objArray = (object[]) array;
                        }
                        int num6 = numArray3[0] + 1;
                        if (objArray != null)
                        {
                            int num7 = lowerBoundA[0] - 1;
                            for (int m = lowerBoundA[0]; m < num6; m++)
                            {
                                if (objArray[m] != null)
                                {
                                    num7 = m;
                                }
                            }
                            num6 = num7 + 1;
                        }
                        for (int k = lowerBoundA[0]; k < num6; k++)
                        {
                            if (objArray == null)
                            {
                                this.WriteArrayMember(objectInfo, arrayElemTypeNameInfo, array.GetValue(k));
                            }
                            else
                            {
                                this.WriteArrayMember(objectInfo, arrayElemTypeNameInfo, objArray[k]);
                            }
                        }
                    }
                    goto Label_053D;

                case InternalArrayTypeE.Jagged:
                {
                    int index = arrayNameInfo.NIname.IndexOf('[');
                    if (index < 0)
                    {
                        throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_Dimensions"), new object[] { arrayElemTypeNameInfo.NIname }));
                    }
                    arrayNameInfo.NIname.Substring(index);
                    arrayNameInfo.NIname = string.Concat(new object[] { arrayElemTypeNameInfo.NIname, "[", lengthA[0], "]" });
                    arrayNameInfo.NIobjectId = objectId;
                    this.serWriter.WriteJaggedArray(memberNameInfo, arrayNameInfo, info, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0]);
                    object[] objArray2 = (object[]) array;
                    for (int n = lowerBoundA[0]; n < (numArray3[0] + 1); n++)
                    {
                        this.WriteArrayMember(objectInfo, arrayElemTypeNameInfo, objArray2[n]);
                    }
                    goto Label_053D;
                }
                default:
                {
                    arrayNameInfo.NIname.IndexOf('[');
                    StringBuilder builder = new StringBuilder(10);
                    builder.Append(arrayElemTypeNameInfo.NIname);
                    builder.Append('[');
                    for (int num12 = 0; num12 < rank; num12++)
                    {
                        builder.Append(lengthA[num12]);
                        if (num12 < (rank - 1))
                        {
                            builder.Append(',');
                        }
                    }
                    builder.Append(']');
                    arrayNameInfo.NIname = builder.ToString();
                    arrayNameInfo.NIobjectId = objectId;
                    this.serWriter.WriteRectangleArray(memberNameInfo, arrayNameInfo, info, arrayElemTypeNameInfo, rank, lengthA, lowerBoundA);
                    flag2 = false;
                    for (int num13 = 0; num13 < rank; num13++)
                    {
                        if (lengthA[num13] == 0)
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    break;
                }
            }
            if (!flag2)
            {
                this.WriteRectangle(objectInfo, rank, lengthA, array, arrayElemTypeNameInfo, lowerBoundA);
            }
        Label_053D:
            this.serWriter.WriteObjectEnd(memberNameInfo, arrayNameInfo);
            this.PutNameInfo(arrayElemTypeNameInfo);
            this.PutNameInfo(arrayNameInfo);
            if (flag)
            {
                this.PutNameInfo(memberNameInfo);
            }
        }
コード例 #29
0
        internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA)
        {
            string str = Convert.ToBase64String(byteA);

            this.attrList.Clear();
            if (memberNameInfo.NIobjectId == this.topId)
            {
                this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
            }
            if (arrayNameInfo.NIobjectId > 1L)
            {
                this.attrList.Put("id", this.IdToString((int)arrayNameInfo.NIobjectId));
            }
            this.attrList.Put("xsi:type", "SOAP-ENC:base64");
            this.isUsedEnc = true;
            string name = this.MemberElementName(memberNameInfo, null);

            this.NamespaceAttribute();
            this.Write(InternalElementTypeE.Member, name, this.attrList, str, true, false);
        }
コード例 #30
0
 private void WriteArrayMember(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, object data)
 {
     arrayElemTypeNameInfo.NIisArrayItem = true;
     if (!this.CheckForNull(objectInfo, arrayElemTypeNameInfo, arrayElemTypeNameInfo, data))
     {
         NameInfo typeNameInfo = null;
         Type type = null;
         bool flag = false;
         if (arrayElemTypeNameInfo.NItransmitTypeOnMember)
         {
             flag = true;
         }
         if (!flag && !arrayElemTypeNameInfo.NIisSealed)
         {
             type = this.GetType(data);
             if (arrayElemTypeNameInfo.NItype != type)
             {
                 flag = true;
             }
         }
         if (flag)
         {
             if (type == null)
             {
                 type = this.GetType(data);
             }
             typeNameInfo = this.TypeToNameInfo(type);
             typeNameInfo.NItransmitTypeOnMember = true;
             typeNameInfo.NIobjectId = arrayElemTypeNameInfo.NIobjectId;
             typeNameInfo.NIassemId = arrayElemTypeNameInfo.NIassemId;
             typeNameInfo.NIisArrayItem = true;
             typeNameInfo.NIitemName = arrayElemTypeNameInfo.NIitemName;
         }
         else
         {
             typeNameInfo = arrayElemTypeNameInfo;
             typeNameInfo.NIisArrayItem = true;
         }
         if (!this.WriteKnownValueClass(arrayElemTypeNameInfo, typeNameInfo, data, false))
         {
             object obj2 = data;
             if (typeNameInfo.NItype.IsEnum)
             {
                 WriteObjectInfo info2 = WriteObjectInfo.Serialize(obj2, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, null, this);
                 typeNameInfo.NIassemId = this.GetAssemblyId(info2);
                 this.WriteEnum(arrayElemTypeNameInfo, typeNameInfo, data, false);
             }
             else
             {
                 long num = this.Schedule(obj2, typeNameInfo.NItype);
                 arrayElemTypeNameInfo.NIobjectId = num;
                 typeNameInfo.NIobjectId = num;
                 if (num < 1L)
                 {
                     WriteObjectInfo info3 = WriteObjectInfo.Serialize(obj2, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, null, this);
                     info3.objectId = num;
                     info3.assemId = this.GetAssemblyId(info3);
                     if (type == null)
                     {
                         type = this.GetType(data);
                     }
                     if ((data != null) && type.IsArray)
                     {
                         this.WriteArray(info3, typeNameInfo, null);
                     }
                     else
                     {
                         typeNameInfo.NIisNestedObject = true;
                         NameInfo info4 = this.TypeToNameInfo(info3);
                         info4.NIobjectId = num;
                         info3.objectId = num;
                         this.Write(info3, typeNameInfo, info4);
                     }
                     info3.ObjectEnd();
                 }
                 else
                 {
                     this.serWriter.WriteItemObjectRef(arrayElemTypeNameInfo, (int) num);
                 }
             }
         }
         if (arrayElemTypeNameInfo.NItransmitTypeOnMember)
         {
             this.PutNameInfo(typeNameInfo);
         }
     }
 }
コード例 #31
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Iterates over a Rectangle array, for each element of the array invokes WriteArrayMember

        private void WriteRectangle(WriteObjectInfo objectInfo, int rank, int[] maxA, System.Array array, NameInfo arrayElemNameTypeInfo, int[] lowerBoundA)
        {
            IndexTraceMessage("WriteRectangle  Entry "+rank, maxA);
            int[] currentA = new int[rank];
            int[] indexMap = null;
            bool isLowerBound = false;
            if (lowerBoundA != null)
            {
                for (int i=0; i<rank; i++)
                {
                    if (lowerBoundA[i] != 0)
                        isLowerBound = true;
                }
            }
            if (isLowerBound)
                indexMap = new int[rank];

            bool isLoop = true;
            while (isLoop)
            {
                isLoop = false;
                if (isLowerBound)
                {
                    for (int i=0; i<rank; i++)
                        indexMap[i] = currentA[i]+lowerBoundA[i];
                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(indexMap));
                }
                else
                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(currentA));          
                for (int irank = rank-1; irank>-1; irank--)
                {
                    // Find the current or lower dimension which can be incremented.
                    if (currentA[irank] < maxA[irank]-1)
                    {
                        // The current dimension is at maximum. Increase the next lower dimension by 1
                        currentA[irank]++;
                        if (irank < rank-1)
                        {
                            // The current dimension and higher dimensions are zeroed.
                            for (int i = irank+1; i<rank; i++)
                                currentA[i] = 0;
                        }
                        isLoop = true;
                        break;                  
                    }

                }
            }
            InternalST.Soap( this, "WriteRectangle  Exit ");
        }
コード例 #32
0
 internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
 {
     this.attrList.Clear();
     if (memberNameInfo.NIobjectId == this.topId)
     {
         this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
     }
     if (arrayNameInfo.NIobjectId > 1L)
     {
         this.attrList.Put("id", this.IdToString((int) arrayNameInfo.NIobjectId));
     }
     arrayElemTypeNameInfo.NIitemName = "SOAP-ENC:Array";
     this.isUsedEnc = true;
     this.attrList.Put("SOAP-ENC:arrayType", this.TypeArrayNameTagResolver(memberNameInfo, arrayNameInfo, true));
     if (lowerBound != 0)
     {
         this.attrList.Put("SOAP-ENC:offset", "[" + lowerBound + "]");
     }
     string name = this.MemberElementName(memberNameInfo, null);
     this.NamespaceAttribute();
     this.Write(InternalElementTypeE.ObjectBegin, name, this.attrList, null, false, false);
 }
コード例 #33
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes a null member into the stream
        private bool CheckForNull(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, Object data)
        {
            InternalST.Soap( this, "CheckForNull Entry data ",Util.PString(data),", memberType ",Util.PString(typeNameInfo.NItype));

            bool isNull = false;

            if (data == null) // || Convert.IsDBNull(data)
                isNull = true;

            // Optimization, Null members are only written for Binary
            if (isNull)
            {
                InternalST.Soap( this, "CheckForNull Write");

                if (typeNameInfo.NItype.IsArray)
                {
                    // Call can occur before typeNameInfo.NIisArray is set
                    ArrayNameToDisplayName(objectInfo, typeNameInfo);
                }

                if (typeNameInfo.NIisArrayItem)
                    serWriter.WriteNullItem(memberNameInfo, typeNameInfo);
                else
                    serWriter.WriteNullMember(memberNameInfo, typeNameInfo);
            }
            InternalST.Soap( this, "CheckForNull Exit ",isNull);
            return isNull;
        }
コード例 #34
0
 internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] objectInfos)
 {
     int nIobjectId = (int) nameInfo.NIobjectId;
     this.attrList.Clear();
     if (nIobjectId == this.topId)
     {
         this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
     }
     if (nIobjectId > 0)
     {
         this.attrList.Put("id", this.IdToString((int) nameInfo.NIobjectId));
     }
     if ((nameInfo.NItransmitTypeOnObject || nameInfo.NItransmitTypeOnMember) && (nameInfo.NIisNestedObject || nameInfo.NIisArrayItem))
     {
         this.attrList.Put("xsi:type", this.TypeNameTagResolver(typeNameInfo, true));
     }
     if (nameInfo.NIisMustUnderstand)
     {
         this.attrList.Put("SOAP-ENV:mustUnderstand", "1");
         this.isUsedEnc = true;
     }
     if (nameInfo.NIisHeader)
     {
         this.attrList.Put("xmlns:" + nameInfo.NIheaderPrefix, nameInfo.NInamespace);
         this.attrList.Put("SOAP-ENC:root", "1");
     }
     if (this.attrValueList.Count > 0)
     {
         for (int i = 0; i < this.attrValueList.Count; i++)
         {
             string str;
             string str2;
             this.attrValueList.Get(i, out str, out str2);
             this.attrList.Put(str, str2);
         }
         this.attrValueList.Clear();
     }
     string name = this.MemberElementName(nameInfo, typeNameInfo);
     this.NamespaceAttribute();
     this.Write(InternalElementTypeE.ObjectBegin, name, this.attrList, null, true, false);
 }
コード例 #35
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
 private NameInfo TypeToNameInfo(WriteObjectInfo objectInfo, NameInfo nameInfo)
 {
     return TypeToNameInfo(objectInfo.objectType, objectInfo, Converter.ToCode(objectInfo.objectType), nameInfo);
 }
コード例 #36
0
 internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA)
 {
     string str = Convert.ToBase64String(byteA);
     this.attrList.Clear();
     if (memberNameInfo.NIobjectId == this.topId)
     {
         this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
     }
     if (arrayNameInfo.NIobjectId > 1L)
     {
         this.attrList.Put("id", this.IdToString((int) arrayNameInfo.NIobjectId));
     }
     this.attrList.Put("xsi:type", "SOAP-ENC:base64");
     this.isUsedEnc = true;
     string name = this.MemberElementName(memberNameInfo, null);
     this.NamespaceAttribute();
     this.Write(InternalElementTypeE.Member, name, this.attrList, str, true, false);
 }
コード例 #37
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Transforms an Array to the serialized string form.

        private NameInfo ArrayTypeToNameInfo(WriteObjectInfo objectInfo, out NameInfo arrayElemTypeNameInfo)
        {
            InternalST.Soap( this, "ArrayTypeToNameInfo Entry ",objectInfo.objectType);

            NameInfo arrayNameInfo = TypeToNameInfo(objectInfo);
            //arrayElemTypeNameInfo = TypeToNameInfo(objectInfo.objectType.GetElementType());
            arrayElemTypeNameInfo = TypeToNameInfo(objectInfo.arrayElemObjectInfo);
            // Need to substitute XDR type for URT type in array.
            // E.g. Int32[] becomes I4[]
            ArrayNameToDisplayName(objectInfo, arrayElemTypeNameInfo);
            arrayNameInfo.NInameSpaceEnum = arrayElemTypeNameInfo.NInameSpaceEnum;
            arrayElemTypeNameInfo.NIisArray = arrayElemTypeNameInfo.NItype.IsArray;

            InternalST.Soap( this, "ArrayTypeToNameInfo Exit array ",arrayNameInfo.NIname," element ",arrayElemTypeNameInfo.NIname);            
            return arrayNameInfo;
        }
コード例 #38
0
 internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
 {
     this.sbOffset.Length = 0;
     this.sbOffset.Append("[");
     bool flag = true;
     for (int i = 0; i < rank; i++)
     {
         if (lowerBoundA[i] != 0)
         {
             flag = false;
         }
         if (i > 0)
         {
             this.sbOffset.Append(",");
         }
         this.sbOffset.Append(lowerBoundA[i]);
     }
     this.sbOffset.Append("]");
     this.attrList.Clear();
     if (memberNameInfo.NIobjectId == this.topId)
     {
         this.Write(InternalElementTypeE.ObjectBegin, "SOAP-ENV:Body", this.attrList, null, false, false);
     }
     if (arrayNameInfo.NIobjectId > 1L)
     {
         this.attrList.Put("id", this.IdToString((int) arrayNameInfo.NIobjectId));
     }
     arrayElemTypeNameInfo.NIitemName = this.NameTagResolver(arrayElemTypeNameInfo, true);
     this.attrList.Put("SOAP-ENC:arrayType", this.TypeArrayNameTagResolver(memberNameInfo, arrayNameInfo, true));
     this.isUsedEnc = true;
     if (!flag)
     {
         this.attrList.Put("SOAP-ENC:offset", this.sbOffset.ToString());
     }
     string name = this.MemberElementName(memberNameInfo, null);
     this.NamespaceAttribute();
     this.Write(InternalElementTypeE.ObjectBegin, name, this.attrList, null, false, false);
 }
コード例 #39
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            //use objectInfo to get assembly string with new criteria
            InternalST.Soap( this, "GetAssemblyId Entry ",objectInfo.objectType," isSi ",objectInfo.isSi);
            long assemId = 0;
            bool isNew = false;
            String assemblyString = objectInfo.GetAssemblyString();
            String serializedAssemblyString = assemblyString;
            if (assemblyString.Length == 0)
            {
                // Fake type could returns an empty string
                assemId = 0;
            }
            else if (assemblyString.Equals(Converter.urtAssemblyString))
            {
                // Urt type is an assemId of 0. No assemblyString needs
                // to be sent but for soap, dotted names need to be placed in header
                InternalST.Soap( this, "GetAssemblyId urt Assembly String ");
                assemId = 0;
                isNew = false;
                serWriter.WriteAssembly(objectInfo.GetTypeFullName(), objectInfo.objectType, null, (int)assemId, isNew, objectInfo.IsAttributeNameSpace());
            }
            else
            {
                // Assembly needs to be sent
                // Need to prefix assembly string to separate the string names from the
                // assemblyName string names. That is a string can have the same value
                // as an assemblyNameString, but it is serialized differently

                if (assemblyToIdTable.ContainsKey(assemblyString))
                {
                    assemId = (long)assemblyToIdTable[assemblyString];
                    isNew = false;
                }
                else
                {
                    assemId = m_idGenerator.GetId("___AssemblyString___"+assemblyString, out isNew);
                    assemblyToIdTable[assemblyString] = assemId;
                }

                if (assemblyString != null && !objectInfo.IsInteropNameSpace())
                {
                    if (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple)
                    {
                        // Use only the simple assembly name (not version or strong name)
                        int index = assemblyString.IndexOf(',');
                        if (index > 0)
                            serializedAssemblyString = assemblyString.Substring(0, index);
                    }
                }
                serWriter.WriteAssembly(objectInfo.GetTypeFullName(), objectInfo.objectType, serializedAssemblyString, (int)assemId, isNew, objectInfo.IsInteropNameSpace());
            }
            InternalST.Soap( this, "GetAssemblyId Exit id ",assemId," isNew ",isNew," assemblyString ",serializedAssemblyString);
            return assemId;
        }
コード例 #40
0
ファイル: soapobjectinfo.cs プロジェクト: ArildF/masters
        // Write constructor
        internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            InternalST.Soap( this, objectInfoId," Constructor 1 ",obj);        
            this.context = context;
            this.obj = obj;
            this.serObjectInfoInit = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector = surrogateSelector;
            this.converter = converter;
            ISurrogateSelector surrogateSelectorTemp;

            if (RemotingServices.IsTransparentProxy(obj))
                objectType = Converter.typeofMarshalByRefObject;
            else
                objectType = obj.GetType();

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo = GetTypeAttributeInfo();
                isArray = true;
                InitNoMembers();
                return;
            }

            InternalST.Soap( this, objectInfoId," Constructor 1 trace 2");

            typeAttributeInfo = GetTypeAttributeInfo();

            if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
            {
                InternalST.Soap( this, objectInfoId," Constructor 1 trace 3");         
                si = new SerializationInfo(objectType, converter);
                if (!objectType.IsPrimitive)
                    serializationSurrogate.GetObjectData(obj, si, context);
                InitSiWrite();
            }
            else if (obj is ISerializable)
            {
                if (!objectType.IsSerializable)
                {
                    throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_NonSerType"), 
                                                                   objectType.FullName, objectType.Module.Assembly.FullName));
                }
                si = new SerializationInfo(objectType, converter);
                ((ISerializable)obj).GetObjectData(si, context);
                InternalST.Soap( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType);                       
                InitSiWrite();
            }
            else
            {
                InternalST.Soap(this, objectInfoId," Constructor 1 trace 5");
                InitMemberInfo();
            }
        }
コード例 #41
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);        
        }
コード例 #42
0
ファイル: soapobjectinfo.cs プロジェクト: ArildF/masters
        // Write Constructor used for array types or null members
        internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {

            InternalST.Soap( this, objectInfoId," Constructor 2 ",objectType);     

            this.objectType = objectType;
            this.context = context;
            this.serObjectInfoInit = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;         
            this.surrogateSelector = surrogateSelector;
            this.converter = converter;

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo = GetTypeAttributeInfo();
                InitNoMembers();
                return;         
            }

            typeAttributeInfo = GetTypeAttributeInfo();

            ISurrogateSelector surrogateSelectorTemp = null;

            if (surrogateSelector!=null)
                serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);

            if (serializationSurrogate != null)
            {
                isSi = true;
            }
            else if (objectType == Converter.typeofObject)
            {
            }
            else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
                isSi = true;

            if (isSi)
            {
                si = new SerializationInfo(objectType, converter);
                cache = new SerObjectInfoCache();
                cache.fullTypeName = si.FullTypeName;
                cache.assemblyString = si.AssemblyName;
            }
            else
            {
                InitMemberInfo();
            }

            InternalST.Soap( this,objectInfoId," ", objectType," InitSerialize Exit ",isSi);       
        }
コード例 #43
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        private void WriteMemberSetup(WriteObjectInfo objectInfo,      
                                      NameInfo memberNameInfo,           
                                      NameInfo typeNameInfo,             
                                      String memberName,             
                                      Type memberType,               
                                      Object memberData,                 
                                      WriteObjectInfo memberObjectInfo,
                                      bool isAttribute
                                     )
        {
            NameInfo newMemberNameInfo = MemberToNameInfo(memberName); 
            // newMemberNameInfo contains the member type

            if (memberObjectInfo != null)
                newMemberNameInfo.NIassemId = memberObjectInfo.assemId;
            newMemberNameInfo.NItype = memberType;

            // newTypeNameInfo contains the data type
            NameInfo newTypeNameInfo = null;
            if (memberObjectInfo == null)
            {
                newTypeNameInfo = TypeToNameInfo(memberType);
            }
            else
            {
                newTypeNameInfo = TypeToNameInfo(memberObjectInfo);
            }

            newMemberNameInfo.NIisRemoteRecord = typeNameInfo.NIisRemoteRecord;

            newMemberNameInfo.NItransmitTypeOnObject = memberNameInfo.NItransmitTypeOnObject;
            newMemberNameInfo.NIisParentTypeOnObject = memberNameInfo.NIisParentTypeOnObject;               
            WriteMembers(newMemberNameInfo, newTypeNameInfo, memberData, objectInfo, typeNameInfo, memberObjectInfo, isAttribute);
            PutNameInfo(newMemberNameInfo);
            PutNameInfo(newTypeNameInfo);
        }
コード例 #44
0
ファイル: soapobjectinfo.cs プロジェクト: ArildF/masters
        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo objectInfo = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                objectInfo.InternalInit();
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
            }
            else
            {
                objectInfo = new WriteObjectInfo();
                objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;                        
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");				
            }

            return objectInfo;
        }
コード例 #45
0
ファイル: soapobjectwriter.cs プロジェクト: ArildF/masters
        // Writes out an array
        private void WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)          
        {
            InternalST.Soap( this, "WriteArray Entry ",objectInfo.obj," ",objectInfo.objectId);

            bool isAllocatedMemberNameInfo = false;
            if (memberNameInfo == null)
            {
                memberNameInfo = TypeToNameInfo(objectInfo);
                memberNameInfo.NIisTopLevelObject = true;
                isAllocatedMemberNameInfo = true;
            }

            memberNameInfo.NIisArray = true;

            long objectId = objectInfo.objectId;
            memberNameInfo.NIobjectId = objectInfo.objectId;

            // Get array type
            System.Array array = (System.Array)objectInfo.obj;
            //Type arrayType = array.GetType();
            Type arrayType = objectInfo.objectType;         

            // Get type of array element 
            Type arrayElemType = arrayType.GetElementType();
            WriteObjectInfo arrayElemObjectInfo = WriteObjectInfo.Serialize(arrayElemType, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, (memberObjectInfo == null) ? null : memberObjectInfo.typeAttributeInfo);
            arrayElemObjectInfo.assemId = GetAssemblyId(arrayElemObjectInfo);


            NameInfo arrayElemTypeNameInfo = null;
            NameInfo arrayNameInfo = ArrayTypeToNameInfo(objectInfo, out arrayElemTypeNameInfo);
            arrayNameInfo.NIobjectId = objectId;
            arrayNameInfo.NIisArray = true;
            arrayElemTypeNameInfo.NIobjectId = objectId;
            arrayElemTypeNameInfo.NItransmitTypeOnMember = memberNameInfo.NItransmitTypeOnMember;
            arrayElemTypeNameInfo.NItransmitTypeOnObject = memberNameInfo.NItransmitTypeOnObject;
            arrayElemTypeNameInfo.NIisParentTypeOnObject = memberNameInfo.NIisParentTypeOnObject;

            // Get rank and length information
            int rank = array.Rank;
            int[] lengthA = new int[rank];
            int[] lowerBoundA = new int[rank];
            int[] upperBoundA = new int[rank];                  
            for (int i=0; i<rank; i++)
            {
                lengthA[i] = array.GetLength(i);
                lowerBoundA[i] = array.GetLowerBound(i);
                upperBoundA[i] = array.GetUpperBound(i);                            
            }

            InternalArrayTypeE arrayEnum;

            if (arrayElemType.IsArray)
            {
                if (rank == 1)
                    arrayEnum = InternalArrayTypeE.Jagged;
                else
                    arrayEnum = InternalArrayTypeE.Rectangular;
            }
            else if (rank == 1)
                arrayEnum = InternalArrayTypeE.Single;
            else
                arrayEnum = InternalArrayTypeE.Rectangular;

            InternalST.Soap( this, "WriteArray ArrayInfo type ",arrayType," rank ",rank);


            // Byte array
            if ((arrayElemType == Converter.typeofByte) && (rank == 1) && (lowerBoundA[0] == 0))
            {
                serWriter.WriteObjectByteArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], (byte[])array);
                return;
            }

            if (arrayElemType == Converter.typeofObject)
            {
                memberNameInfo.NItransmitTypeOnMember = true;
                arrayElemTypeNameInfo.NItransmitTypeOnMember = true;
            }

            if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
            {
                memberNameInfo.NItransmitTypeOnObject = true;
                arrayElemTypeNameInfo.NItransmitTypeOnObject = true;                
            }

            if (arrayEnum == InternalArrayTypeE.Single)
            {
                // Single Dimensional array
                InternalST.Soap( this, "WriteArray ARRAY_SINGLE ");

                arrayNameInfo.NIname = arrayElemTypeNameInfo.NIname+"["+lengthA[0]+"]";

                // BinaryFormatter array of primitive types is written out in the WriteSingleArray statement
                // as a byte buffer
                serWriter.WriteSingleArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], array);

                if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBoundA[0] == 0))
                {
                    // If binaryformatter and array is of appopriate primitive type the array is
                    // written out as a buffer of bytes. The array was transmitted in WriteSingleArray
                    // If soap the index directly by array
                    arrayElemTypeNameInfo.NIobjectId = 0;
                    if (primitiveArray == null)
                        primitiveArray = new PrimitiveArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum, array);
                    else
                        primitiveArray.Init(arrayElemTypeNameInfo.NIprimitiveTypeEnum, array);

                    int upperBound = upperBoundA[0]+1;                      
                    for (int i = lowerBoundA[0]; i < upperBound; i++)
                    {
                        serWriter.WriteItemString(arrayElemTypeNameInfo, arrayElemTypeNameInfo, primitiveArray.GetValue(i));
                    }
                }
                else
                {
                    // Non-primitive type array
                    Object[] objectA = null;
                    if (!arrayElemType.IsValueType)
                        objectA = (Object[])array;

                    int upperBound = upperBoundA[0]+1;
                    // Soap does not write out trailing nulls. lastValue is set to the last null value. This becomes the array's upperbound
                    // Note: value classes can't be null
                    if (objectA != null)
                    {
                        int lastValue = lowerBoundA[0]-1;
                        for (int i = lowerBoundA[0]; i< upperBound; i++)
                        {
                            if (objectA[i] != null)
                                lastValue = i;
                        }
                        upperBound = lastValue+1;
                    }

                    for (int i = lowerBoundA[0]; i < upperBound; i++)
                    {
                        if (objectA == null)
                            WriteArrayMember(objectInfo, arrayElemTypeNameInfo, array.GetValue(i));
                        else
                            WriteArrayMember(objectInfo, arrayElemTypeNameInfo, objectA[i]);
                    }
                }
            }
            else if (arrayEnum == InternalArrayTypeE.Jagged)
            {
                // Jagged Array
                InternalST.Soap( this, "WriteArray ARRAY_JAGGED");

                int index;
                String arrayElemTypeDimension = null;

                index = arrayNameInfo.NIname.IndexOf('[');
                if (index < 0)
                    throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_Dimensions"),arrayElemTypeNameInfo.NIname));
                arrayElemTypeDimension = arrayNameInfo.NIname.Substring(index);

                InternalST.Soap( this, "WriteArray arrayNameInfo.NIname ",arrayNameInfo.NIname," arrayElemTypeNameInfo.NIname ",arrayElemTypeNameInfo.NIname," arrayElemTypeDimension ",arrayElemTypeDimension);
                arrayNameInfo.NIname = arrayElemTypeNameInfo.NIname+"["+lengthA[0]+"]";

                arrayNameInfo.NIobjectId = objectId;

                serWriter.WriteJaggedArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0]);

                Object[] objectA = (Object[])array;
                for (int i = lowerBoundA[0]; i < upperBoundA[0]+1; i++)
                {
                    WriteArrayMember(objectInfo, arrayElemTypeNameInfo, objectA[i]);
                }
            }
            else
            {
                // Rectangle Array
                // Get the length for all the ranks
                InternalST.Soap( this, "WriteArray ARRAY_RECTANGLE");                       

                // Express array Type using XmlData Name
                int index;
                index = arrayNameInfo.NIname.IndexOf('[');

                // Create length dimension string in form [3,4,2]
                StringBuilder sb = new StringBuilder(10);
                sb.Append(arrayElemTypeNameInfo.NIname);
                sb.Append('[');

                for (int i=0; i<rank; i++)
                {
                    sb.Append(lengthA[i]);
                    if (i < rank-1)
                        sb.Append(',');
                }
                sb.Append(']');
                arrayNameInfo.NIname = sb.ToString();

                arrayNameInfo.NIobjectId = objectId;
                serWriter.WriteRectangleArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, rank, lengthA, lowerBoundA);


                IndexTraceMessage("WriteArray Rectangle  ", lengthA);

                bool bzero = false;
                for (int i=0; i<rank; i++)
                {
                    if (lengthA[i] == 0)
                    {
                        bzero = true;
                        break;
                    }
                }

                if (!bzero)
                    WriteRectangle(objectInfo, rank, lengthA, array, arrayElemTypeNameInfo, lowerBoundA);
            }

            serWriter.WriteObjectEnd(memberNameInfo, arrayNameInfo); 


            PutNameInfo(arrayElemTypeNameInfo);
            PutNameInfo(arrayNameInfo);
            if (isAllocatedMemberNameInfo)
                PutNameInfo(memberNameInfo);

            InternalST.Soap( this, "WriteArray Exit ");
        }
コード例 #46
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE none = InternalNameSpaceE.None;

            typeName = null;
            if (code != InternalPrimitiveTypeE.Invalid)
            {
                if (code == InternalPrimitiveTypeE.Char)
                {
                    none     = InternalNameSpaceE.UrtSystem;
                    typeName = "System.Char";
                }
                else
                {
                    none     = InternalNameSpaceE.XdrPrimitive;
                    typeName = ToXmlDataType(code);
                }
            }
            if ((none == InternalNameSpaceE.None) && (type != null))
            {
                if (type == typeofString)
                {
                    none = InternalNameSpaceE.XdrString;
                }
                else if (objectInfo == null)
                {
                    typeName = type.FullName;
                    if (type.Module.Assembly == urtAssembly)
                    {
                        none = InternalNameSpaceE.UrtSystem;
                    }
                    else
                    {
                        none = InternalNameSpaceE.UrtUser;
                    }
                }
                else
                {
                    typeName = objectInfo.GetTypeFullName();
                    if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
                    {
                        none = InternalNameSpaceE.UrtSystem;
                    }
                    else
                    {
                        none = InternalNameSpaceE.UrtUser;
                    }
                }
            }
            if (objectInfo != null)
            {
                if (!objectInfo.isSi && ((objectInfo.IsAttributeNameSpace() || objectInfo.IsCustomXmlAttribute()) || objectInfo.IsCustomXmlElement()))
                {
                    return(InternalNameSpaceE.Interop);
                }
                if (objectInfo.IsCallElement())
                {
                    none = InternalNameSpaceE.CallElement;
                }
            }
            return(none);
        }