GetResourceString() static private method

static private GetResourceString ( String key ) : String
key String
return String
Beispiel #1
0
        public object Deserialize(Stream serializationStream, HeaderHandler handler)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }
            if (serializationStream.CanSeek && (serializationStream.Length == 0L))
            {
                throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
            }
            InternalFE formatterEnums = new InternalFE {
                FEtypeFormat         = this.m_typeFormat,
                FEtopObject          = this.m_topObject,
                FEserializerTypeEnum = InternalSerializerTypeE.Soap,
                FEassemblyFormat     = this.m_assemblyFormat,
                FEsecurityLevel      = this.m_securityLevel
            };
            ObjectReader objectReader = new ObjectReader(serializationStream, this.m_surrogates, this.m_context, formatterEnums, this.m_binder);

            if ((this.soapParser == null) || (serializationStream != this.currentStream))
            {
                this.soapParser    = new SoapParser(serializationStream);
                this.currentStream = serializationStream;
            }
            this.soapParser.Init(objectReader);
            return(objectReader.Deserialize(handler, this.soapParser));
        }
 internal Object Next()
 {
     if (next > top)
     {
         throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_StackRange"), stackId));
     }
     return(objects[next++]);
 }
 internal void GetMemberInfo(out string[] outMemberNames, out Type[] outMemberTypes, out object[] outMemberData, out SoapAttributeInfo[] outAttributeInfo)
 {
     outMemberNames   = this.cache.memberNames;
     outMemberTypes   = this.cache.memberTypes;
     outMemberData    = this.memberData;
     outAttributeInfo = this.cache.memberAttributeInfos;
     if (this.isSi && !this.isNamed)
     {
         throw new SerializationException(SoapUtil.GetResourceString("Serialization_ISerializableMemberInfo"));
     }
 }
Beispiel #4
0
        // Fills in the values for an object
        internal void PopulateObjectMembers()
        {
            InternalST.Soap(this, objectInfoId, " ", objectType, " PopulateObjectMembers  isSi ", isSi);
            if (!isSi)
            {
                MemberInfo[] finalMemberInfos = null;
                Object[]     finalMemberData  = null;
                int          finalMemberIndex = 0;

                if (numberMembersSeen < memberNames.Length)
                {
                    finalMemberInfos = new MemberInfo[numberMembersSeen];
                    finalMemberData  = new Object[numberMembersSeen];

                    for (int iMember = 0; iMember < memberNames.Length; ++iMember)
                    {
                        if (memberNames[iMember] == null)
                        {
                            // A field on the type isnt found. See if the field has OptionallySerializable and the type has the deserialization constructor
                            Object [] attrs = cache.memberInfos[iMember].GetCustomAttributes(typeof(OptionalFieldAttribute), false);
                            if ((attrs == null || attrs.Length == 0) && (majorVersion >= 1 && minorVersion >= 0))
                            {
                                // the member isnt optionally serializable
                                throw new SerializationException(SoapUtil.GetResourceString("Serialization_WrongNumberOfMembers",
                                                                                            objectType, cache.memberInfos.Length, numberMembersSeen));
                            }
                        }
                        else
                        {
                            if (memberNames[iMember] != cache.memberInfos[iMember].Name)
                            {
                                throw new SerializationException(SoapUtil.GetResourceString("Serialization_WrongNumberOfMembers",
                                                                                            objectType, cache.memberInfos.Length, numberMembersSeen));
                            }

                            finalMemberInfos[finalMemberIndex] = cache.memberInfos[iMember];
                            finalMemberData[finalMemberIndex]  = memberData[iMember];
                            finalMemberIndex++;
                        }
                    }
                }
                else
                {
                    finalMemberInfos = cache.memberInfos;
                    finalMemberData  = memberData;
                }


                DumpPopulate(finalMemberInfos, finalMemberData);

                FormatterServices.PopulateObjectMembers(obj, finalMemberInfos, finalMemberData);
                numberMembersSeen = 0;
            }
        }
 internal Assembly GetAssembly(ObjectReader objectReader)
 {
     if (assembly == null)
     {
         assembly = objectReader.LoadAssemblyFromString(assemblyString);
         if (assembly == null)
         {
             throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_AssemblyString"), assemblyString));
         }
     }
     return(assembly);
 }
        internal virtual void Fixup(ParseRecord record, ParseRecord parent)
        {
            Object obj = record.PRnewObj;

            InternalST.Soap(this, "Fixup ", obj, " ", ((Enum)valueFixupEnum).ToString());

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

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

            case ValueFixupEnum.Member:

                InternalST.Soap(this, "Fixup Member new object value ", obj, " memberObject ", memberObject);

                if (objectInfo.isSi)
                {
                    InternalST.Soap(this, "Recording a fixup on member: ", memberName,
                                    " in object id", parent.PRobjectId, " Required Object ", record.PRobjectId);
                    objectInfo.objectManager.RecordDelayedFixup(parent.PRobjectId, memberName, record.PRobjectId);
                }
                else
                {
                    MemberInfo memberInfo = objectInfo.GetMemberInfo(memberName);
                    InternalST.Soap(this, "Recording a fixup on member:", memberInfo, " in object id ",
                                    parent.PRobjectId, " Required Object", record.PRobjectId);
                    objectInfo.objectManager.RecordFixup(parent.PRobjectId, memberInfo, record.PRobjectId);
                }
                break;
            }
        }
Beispiel #7
0
 internal void PopulateObjectMembers()
 {
     if (!this.isSi)
     {
         MemberInfo[] members = null;
         object[]     data    = null;
         int          index   = 0;
         if (this.numberMembersSeen < this.memberNames.Length)
         {
             members = new MemberInfo[this.numberMembersSeen];
             data    = new object[this.numberMembersSeen];
             for (int i = 0; i < this.memberNames.Length; i++)
             {
                 if (this.memberNames[i] == null)
                 {
                     object[] customAttributes = this.cache.memberInfos[i].GetCustomAttributes(typeof(OptionalFieldAttribute), false);
                     if (((customAttributes == null) || (customAttributes.Length == 0)) && ((this.majorVersion >= 1) && (this.minorVersion >= 0)))
                     {
                         throw new SerializationException(SoapUtil.GetResourceString("Serialization_WrongNumberOfMembers", new object[] { this.objectType, this.cache.memberInfos.Length, this.numberMembersSeen }));
                     }
                 }
                 else
                 {
                     if (this.memberNames[i] != this.cache.memberInfos[i].Name)
                     {
                         throw new SerializationException(SoapUtil.GetResourceString("Serialization_WrongNumberOfMembers", new object[] { this.objectType, this.cache.memberInfos.Length, this.numberMembersSeen }));
                     }
                     members[index] = this.cache.memberInfos[i];
                     data[index]    = this.memberData[i];
                     index++;
                 }
             }
         }
         else
         {
             members = this.cache.memberInfos;
             data    = this.memberData;
         }
         FormatterServices.PopulateObjectMembers(this.obj, members, data);
         this.numberMembersSeen = 0;
     }
 }
Beispiel #8
0
        // Deserialize the stream into an object graph.
        public Object Deserialize(Stream serializationStream, HeaderHandler handler)
        {
            InternalST.InfoSoap("Enter SoapFormatter.Deserialize ");
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }

            if (serializationStream.CanSeek && (serializationStream.Length == 0))
            {
                throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
            }

            InternalST.Soap(this, "Deserialize Entry");
            InternalFE formatterEnums = new InternalFE();

            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEtopObject          = m_topObject;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Soap;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            formatterEnums.FEsecurityLevel      = m_securityLevel;
            ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);

            // If this is the first call, or a new stream is being used a new Soap parser is created.
            // If this is a continuing call, then the existing SoapParser is used.
            // One stream can contains multiple Soap XML documents. The XMLParser buffers the XML so
            // that the same XMLParser has to be used to continue a stream.
            if ((soapParser == null) || (serializationStream != currentStream))
            {
                soapParser    = new SoapParser(serializationStream);
                currentStream = serializationStream;
            }
            soapParser.Init(sor);
            Object obj = sor.Deserialize(handler, soapParser);

            InternalST.InfoSoap("Leave SoapFormatter.Deserialize ");
            return(obj);
        }
Beispiel #9
0
        internal Type GetType(int position)
        {
            InternalST.Soap(this, objectInfoId, " ", objectType, " GetType Entry ByPosition ", position);
            Type type = null;

            if (isTyped)
            {
                if (position >= cache.memberTypes.Length)
                {
                    throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_ISerializableTypes"), objectType + " " + position));
                }
                type = cache.memberTypes[position];

                InternalST.Soap(this, objectInfoId, " ", objectType, " GetType Exit ByPosition ", type);
            }
            return(type);
        }
Beispiel #10
0
        // Get the ObjectType for a memberName
        internal Type GetType(String name)
        {
            InternalST.Soap(this, objectInfoId, " ", objectType, " GetType Entry ", name);
            Type type = null;

            if (isTyped)
            {
                type = cache.memberTypes[Position(name)];
            }
            else
            {
                type = (Type)memberTypesList[Position(name)];
            }

            if (type == null)
            {
                throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_ISerializableTypes"), objectType + " " + name));
            }

            InternalST.Soap(this, objectInfoId, " ", objectType, " GetType Exit ", type);
            return(type);
        }
Beispiel #11
0
        internal Type GetMemberType(MemberInfo objMember)
        {
            Type objectType = null;

            if (objMember is FieldInfo)
            {
                objectType = ((FieldInfo)objMember).FieldType;
                InternalST.Soap(this, objectInfoId, " ", "GetMemberType FieldInfo ", objectType);
            }
            else if (objMember is PropertyInfo)
            {
                objectType = ((PropertyInfo)objMember).PropertyType;
                InternalST.Soap(this, objectInfoId, " ", "GetMemberType PropertyInfo ", objectType);
            }
            else
            {
                throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SerMemberInfo"), objMember.GetType()));
            }

            return(objectType);
        }
Beispiel #12
0
 // Get the memberInfo for a memberName
 internal MemberInfo GetMemberInfo(String name)
 {
     InternalST.Soap(this, objectInfoId, " ", objectType, " GetMemberInfo Entry ", name);
     if (isSi)
     {
         throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_MemberInfo"), objectType + " " + name));
     }
     if (cache.memberInfos == null)
     {
         throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NoMemberInfo"), objectType + " " + name));
     }
     return(cache.memberInfos[Position(name)]);
 }
Beispiel #13
0
        private int Position(String name)
        {
            InternalST.Soap(this, objectInfoId, " Position ", lastPosition, " ", name);
            if (cache.memberNames[lastPosition].Equals(name))
            {
                return(lastPosition);
            }
            else if ((++lastPosition < cache.memberNames.Length) && (cache.memberNames[lastPosition].Equals(name)))
            {
                return(lastPosition);
            }
            else
            {
                // Search for name
                InternalST.Soap(this, objectInfoId, " Position miss search for name " + name);
                for (int i = 0; i < cache.memberNames.Length; i++)
                {
                    if (cache.memberNames[i].Equals(name))
                    {
                        lastPosition = i;
                        return(lastPosition);
                    }
                }

                throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_Position"), objectType + " " + name));
            }
        }
Beispiel #14
0
 internal object Next()
 {
     if (this.next > this.top)
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_StackRange"), new object[] { this.stackId }));
     }
     return(this.objects[this.next++]);
 }
Beispiel #15
0
 private int Position(string name)
 {
     if (this.cache.memberNames[this.lastPosition].Equals(name))
     {
         return(this.lastPosition);
     }
     if ((++this.lastPosition < this.cache.memberNames.Length) && this.cache.memberNames[this.lastPosition].Equals(name))
     {
         return(this.lastPosition);
     }
     for (int i = 0; i < this.cache.memberNames.Length; i++)
     {
         if (this.cache.memberNames[i].Equals(name))
         {
             this.lastPosition = i;
             return(this.lastPosition);
         }
     }
     throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_Position"), new object[] { this.objectType + " " + name }));
 }
Beispiel #16
0
        internal Type GetType(string name)
        {
            Type type = null;

            if (this.isTyped)
            {
                type = this.cache.memberTypes[this.Position(name)];
            }
            else
            {
                type = (Type)this.memberTypesList[this.Position(name)];
            }
            if (type == null)
            {
                throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_ISerializableTypes"), new object[] { this.objectType + " " + name }));
            }
            return(type);
        }
        internal static InternalPrimitiveTypeE ToCode(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("serParser", string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("ArgumentNull_WithParamName"), new object[] { value }));
            }
            string str = value.ToLower(CultureInfo.InvariantCulture);
            char   ch  = str[0];
            InternalPrimitiveTypeE invalid = InternalPrimitiveTypeE.Invalid;

            switch (ch)
            {
            case 'a':
                if (str == "anyuri")
                {
                    invalid = InternalPrimitiveTypeE.AnyUri;
                }
                return(invalid);

            case 'b':
                if (!(str == "boolean"))
                {
                    switch (str)
                    {
                    case "byte":
                        return(InternalPrimitiveTypeE.SByte);

                    case "base64binary":
                        return(InternalPrimitiveTypeE.Base64Binary);

                    case "base64":
                        invalid = InternalPrimitiveTypeE.Base64Binary;
                        break;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Boolean);

            case 'c':
                if (!(str == "char") && !(str == "character"))
                {
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Char);

            case 'd':
                switch (str)
                {
                case "double":
                    invalid = InternalPrimitiveTypeE.Double;
                    break;

                case "datetime":
                    return(InternalPrimitiveTypeE.DateTime);

                case "duration":
                    return(InternalPrimitiveTypeE.TimeSpan);

                case "date":
                    return(InternalPrimitiveTypeE.Date);

                case "decimal":
                    invalid = InternalPrimitiveTypeE.Decimal;
                    break;
                }
                return(invalid);

            case 'e':
                if (!(str == "entities"))
                {
                    if (str == "entity")
                    {
                        invalid = InternalPrimitiveTypeE.Entity;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Entities);

            case 'f':
                if (str == "float")
                {
                    invalid = InternalPrimitiveTypeE.Single;
                }
                return(invalid);

            case 'g':
                if (!(str == "gyearmonth"))
                {
                    if (str == "gyear")
                    {
                        return(InternalPrimitiveTypeE.Year);
                    }
                    if (str == "gmonthday")
                    {
                        return(InternalPrimitiveTypeE.MonthDay);
                    }
                    if (str == "gday")
                    {
                        return(InternalPrimitiveTypeE.Day);
                    }
                    if (str == "gmonth")
                    {
                        invalid = InternalPrimitiveTypeE.Month;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.YearMonth);

            case 'h':
                if (str == "hexbinary")
                {
                    invalid = InternalPrimitiveTypeE.HexBinary;
                }
                return(invalid);

            case 'i':
                switch (str)
                {
                case "int":
                    invalid = InternalPrimitiveTypeE.Int32;
                    break;

                case "integer":
                    return(InternalPrimitiveTypeE.Integer);

                case "idrefs":
                    return(InternalPrimitiveTypeE.Idrefs);

                case "id":
                    return(InternalPrimitiveTypeE.Id);

                case "idref":
                    invalid = InternalPrimitiveTypeE.Idref;
                    break;
                }
                return(invalid);

            case 'l':
                if (!(str == "long"))
                {
                    if (str == "language")
                    {
                        invalid = InternalPrimitiveTypeE.Language;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Int64);

            case 'n':
                if (!(str == "number"))
                {
                    if (str == "normalizedstring")
                    {
                        return(InternalPrimitiveTypeE.NormalizedString);
                    }
                    if (str == "nonpositiveinteger")
                    {
                        return(InternalPrimitiveTypeE.NonPositiveInteger);
                    }
                    if (str == "negativeinteger")
                    {
                        return(InternalPrimitiveTypeE.NegativeInteger);
                    }
                    if (str == "nonnegativeinteger")
                    {
                        return(InternalPrimitiveTypeE.NonNegativeInteger);
                    }
                    if (str == "notation")
                    {
                        return(InternalPrimitiveTypeE.Notation);
                    }
                    if (str == "nmtoken")
                    {
                        return(InternalPrimitiveTypeE.Nmtoken);
                    }
                    if (str == "nmtokens")
                    {
                        return(InternalPrimitiveTypeE.Nmtokens);
                    }
                    if (str == "name")
                    {
                        return(InternalPrimitiveTypeE.Name);
                    }
                    if (str == "ncname")
                    {
                        invalid = InternalPrimitiveTypeE.NcName;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Decimal);

            case 'p':
                if (str == "positiveinteger")
                {
                    invalid = InternalPrimitiveTypeE.PositiveInteger;
                }
                return(invalid);

            case 'q':
                if (str == "qname")
                {
                    invalid = InternalPrimitiveTypeE.QName;
                }
                return(invalid);

            case 's':
                if (!(str == "short"))
                {
                    if (str == "system.byte")
                    {
                        return(InternalPrimitiveTypeE.Byte);
                    }
                    if (str == "system.sbyte")
                    {
                        return(InternalPrimitiveTypeE.SByte);
                    }
                    if (str == "system")
                    {
                        return(ToCode(value.Substring(7)));
                    }
                    if (str == "system.runtime.remoting.metadata")
                    {
                        invalid = ToCode(value.Substring(0x21));
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Int16);

            case 't':
                if (!(str == "time"))
                {
                    if (str == "token")
                    {
                        return(InternalPrimitiveTypeE.Token);
                    }
                    if (str == "timeinstant")
                    {
                        return(InternalPrimitiveTypeE.DateTime);
                    }
                    if (str == "timeduration")
                    {
                        invalid = InternalPrimitiveTypeE.TimeSpan;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.Time);

            case 'u':
                if (!(str == "unsignedlong"))
                {
                    if (str == "unsignedint")
                    {
                        return(InternalPrimitiveTypeE.UInt32);
                    }
                    if (str == "unsignedshort")
                    {
                        return(InternalPrimitiveTypeE.UInt16);
                    }
                    if (str == "unsignedbyte")
                    {
                        invalid = InternalPrimitiveTypeE.Byte;
                    }
                    return(invalid);
                }
                return(InternalPrimitiveTypeE.UInt64);
            }
            return(InternalPrimitiveTypeE.Invalid);
        }
Beispiel #18
0
        internal Type GetType(int position)
        {
            Type type = null;

            if (!this.isTyped)
            {
                return(type);
            }
            if (position >= this.cache.memberTypes.Length)
            {
                throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_ISerializableTypes"), new object[] { this.objectType + " " + position }));
            }
            return(this.cache.memberTypes[position]);
        }
Beispiel #19
0
 internal Type GetMemberType(MemberInfo objMember)
 {
     if (objMember is FieldInfo)
     {
         return(((FieldInfo)objMember).FieldType);
     }
     if (!(objMember is PropertyInfo))
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_SerMemberInfo"), new object[] { objMember.GetType() }));
     }
     return(((PropertyInfo)objMember).PropertyType);
 }
Beispiel #20
0
 internal MemberInfo GetMemberInfo(string name)
 {
     if (this.isSi)
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_MemberInfo"), new object[] { this.objectType + " " + name }));
     }
     if (this.cache.memberInfos == null)
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NoMemberInfo"), new object[] { this.objectType + " " + name }));
     }
     return(this.cache.memberInfos[this.Position(name)]);
 }
Beispiel #21
0
        private string NameTagResolver(NameInfo typeNameInfo, bool isXsiAppended, string arrayItemName)
        {
            string nIname = typeNameInfo.NIname;

            switch (typeNameInfo.NInameSpaceEnum)
            {
            case InternalNameSpaceE.None:
            case InternalNameSpaceE.UserNameSpace:
            case InternalNameSpaceE.MemberName:
                return(nIname);

            case InternalNameSpaceE.Soap:
                nIname         = "SOAP-ENC:" + typeNameInfo.NIname;
                this.isUsedEnc = true;
                return(nIname);

            case InternalNameSpaceE.XdrPrimitive:
                if (isXsiAppended)
                {
                    nIname = "xsd:" + typeNameInfo.NIname;
                }
                return(nIname);

            case InternalNameSpaceE.XdrString:
                if (isXsiAppended)
                {
                    nIname = "xsd:" + typeNameInfo.NIname;
                }
                return(nIname);

            case InternalNameSpaceE.UrtSystem:
                if (!(typeNameInfo.NItype == SoapUtil.typeofObject))
                {
                    DottedInfo info3;
                    if (arrayItemName == null)
                    {
                        DottedInfo info;
                        if (this.typeNameToDottedInfoTable.ContainsKey(typeNameInfo.NIname))
                        {
                            info = (DottedInfo)this.typeNameToDottedInfoTable[typeNameInfo.NIname];
                        }
                        else
                        {
                            info = this.ParseAssemblyName(typeNameInfo.NIname, null);
                        }
                        string str2 = this.AssemIdToString(info.assemId);
                        nIname = str2 + ":" + info.name;
                        AssemblyInfo info2 = (AssemblyInfo)this.assemblyInfos[str2];
                        info2.isUsed = true;
                        info2.prefix = str2;
                        this.assemblyInfoUsed[info2] = 1;
                        return(nIname);
                    }
                    if (this.typeNameToDottedInfoTable.ContainsKey(arrayItemName))
                    {
                        info3 = (DottedInfo)this.typeNameToDottedInfoTable[arrayItemName];
                    }
                    else
                    {
                        info3 = this.ParseAssemblyName(arrayItemName, null);
                    }
                    string str3 = this.AssemIdToString(info3.assemId);
                    nIname = str3 + ":" + this.DottedDimensionName(info3.name, typeNameInfo.NIname);
                    AssemblyInfo info4 = (AssemblyInfo)this.assemblyInfos[str3];
                    info4.isUsed = true;
                    info4.prefix = str3;
                    this.assemblyInfoUsed[info4] = 1;
                    return(nIname);
                }
                return("xsd:anyType");

            case InternalNameSpaceE.UrtUser:
                if (typeNameInfo.NIassemId > 0L)
                {
                    if (arrayItemName != null)
                    {
                        if (!this.typeNameToDottedInfoTable.ContainsKey(arrayItemName))
                        {
                            throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_Assembly"), new object[] { typeNameInfo.NIname }));
                        }
                        DottedInfo info7 = (DottedInfo)this.typeNameToDottedInfoTable[arrayItemName];
                        string     str5  = this.AssemIdToString(info7.assemId);
                        nIname = str5 + ":" + this.DottedDimensionName(info7.name, typeNameInfo.NIname);
                        AssemblyInfo info8 = (AssemblyInfo)this.assemblyInfos[str5];
                        info8.isUsed = true;
                        info8.prefix = str5;
                        this.assemblyInfoUsed[info8] = 1;
                        return(nIname);
                    }
                    if (!this.typeNameToDottedInfoTable.ContainsKey(typeNameInfo.NIname))
                    {
                        throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_Assembly"), new object[] { typeNameInfo.NIname }));
                    }
                    DottedInfo info5 = (DottedInfo)this.typeNameToDottedInfoTable[typeNameInfo.NIname];
                    string     str4  = this.AssemIdToString(info5.assemId);
                    nIname = str4 + ":" + info5.name;
                    AssemblyInfo info6 = (AssemblyInfo)this.assemblyInfos[str4];
                    info6.isUsed = true;
                    info6.prefix = str4;
                    this.assemblyInfoUsed[info6] = 1;
                }
                return(nIname);

            case InternalNameSpaceE.Interop:
                if ((typeNameInfo.NIattributeInfo != null) && (typeNameInfo.NIattributeInfo.AttributeElementName != null))
                {
                    if (typeNameInfo.NIassemId <= 0L)
                    {
                        return(typeNameInfo.NIattributeInfo.AttributeElementName);
                    }
                    string str7 = this.InteropAssemIdToString((int)typeNameInfo.NIassemId);
                    nIname = str7 + ":" + typeNameInfo.NIattributeInfo.AttributeElementName;
                    if (arrayItemName != null)
                    {
                        int index = typeNameInfo.NIname.IndexOf("[");
                        nIname = nIname + typeNameInfo.NIname.Substring(index);
                    }
                    AssemblyInfo info10 = (AssemblyInfo)this.assemblyInfos[str7];
                    info10.isUsed = true;
                    info10.prefix = str7;
                    this.assemblyInfoUsed[info10] = 1;
                }
                return(nIname);

            case InternalNameSpaceE.CallElement:
                if (typeNameInfo.NIassemId > 0L)
                {
                    string       str6  = this.InteropAssemIdToString((int)typeNameInfo.NIassemId);
                    AssemblyInfo info9 = (AssemblyInfo)this.assemblyInfos[str6];
                    if (info9 == null)
                    {
                        throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NameSpaceEnum"), new object[] { typeNameInfo.NInameSpaceEnum }));
                    }
                    nIname       = str6 + ":" + typeNameInfo.NIname;
                    info9.isUsed = true;
                    info9.prefix = str6;
                    this.assemblyInfoUsed[info9] = 1;
                    return(nIname);
                }
                return(nIname);
            }
            throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NameSpaceEnum"), new object[] { typeNameInfo.NInameSpaceEnum }));
        }
        internal static object FromString(string value, InternalPrimitiveTypeE code)
        {
            switch (code)
            {
            case InternalPrimitiveTypeE.Boolean:
                if (!(value == "1") && !(value == "true"))
                {
                    if ((value != "0") && (value != "false"))
                    {
                        throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_typeCoercion"), new object[] { value, "Boolean" }));
                    }
                    return(false);
                }
                return(true);

            case InternalPrimitiveTypeE.Double:
                if (!(value == "INF"))
                {
                    if (value == "-INF")
                    {
                        return((double)-1.0 / (double)0.0);
                    }
                    return(double.Parse(value, CultureInfo.InvariantCulture));
                }
                return((double)1.0 / (double)0.0);

            case InternalPrimitiveTypeE.Single:
                if (!(value == "INF"))
                {
                    if (value == "-INF")
                    {
                        return((float)-1.0 / (float)0.0);
                    }
                    return(float.Parse(value, CultureInfo.InvariantCulture));
                }
                return((float)1.0 / (float)0.0);

            case InternalPrimitiveTypeE.TimeSpan:
                return(SoapDuration.Parse(value));

            case InternalPrimitiveTypeE.DateTime:
                return(SoapDateTime.Parse(value));

            case InternalPrimitiveTypeE.Time:
                return(SoapTime.Parse(value));

            case InternalPrimitiveTypeE.Date:
                return(SoapDate.Parse(value));

            case InternalPrimitiveTypeE.YearMonth:
                return(SoapYearMonth.Parse(value));

            case InternalPrimitiveTypeE.Year:
                return(SoapYear.Parse(value));

            case InternalPrimitiveTypeE.MonthDay:
                return(SoapMonthDay.Parse(value));

            case InternalPrimitiveTypeE.Day:
                return(SoapDay.Parse(value));

            case InternalPrimitiveTypeE.Month:
                return(SoapMonth.Parse(value));

            case InternalPrimitiveTypeE.HexBinary:
                return(SoapHexBinary.Parse(value));

            case InternalPrimitiveTypeE.Base64Binary:
                return(SoapBase64Binary.Parse(value));

            case InternalPrimitiveTypeE.Integer:
                return(SoapInteger.Parse(value));

            case InternalPrimitiveTypeE.PositiveInteger:
                return(SoapPositiveInteger.Parse(value));

            case InternalPrimitiveTypeE.NonPositiveInteger:
                return(SoapNonPositiveInteger.Parse(value));

            case InternalPrimitiveTypeE.NonNegativeInteger:
                return(SoapNonNegativeInteger.Parse(value));

            case InternalPrimitiveTypeE.NegativeInteger:
                return(SoapNegativeInteger.Parse(value));

            case InternalPrimitiveTypeE.AnyUri:
                return(SoapAnyUri.Parse(value));

            case InternalPrimitiveTypeE.QName:
                return(SoapQName.Parse(value));

            case InternalPrimitiveTypeE.Notation:
                return(SoapNotation.Parse(value));

            case InternalPrimitiveTypeE.NormalizedString:
                return(SoapNormalizedString.Parse(value));

            case InternalPrimitiveTypeE.Token:
                return(SoapToken.Parse(value));

            case InternalPrimitiveTypeE.Language:
                return(SoapLanguage.Parse(value));

            case InternalPrimitiveTypeE.Name:
                return(SoapName.Parse(value));

            case InternalPrimitiveTypeE.Idrefs:
                return(SoapIdrefs.Parse(value));

            case InternalPrimitiveTypeE.Entities:
                return(SoapEntities.Parse(value));

            case InternalPrimitiveTypeE.Nmtoken:
                return(SoapNmtoken.Parse(value));

            case InternalPrimitiveTypeE.Nmtokens:
                return(SoapNmtokens.Parse(value));

            case InternalPrimitiveTypeE.NcName:
                return(SoapNcName.Parse(value));

            case InternalPrimitiveTypeE.Id:
                return(SoapId.Parse(value));

            case InternalPrimitiveTypeE.Idref:
                return(SoapIdref.Parse(value));

            case InternalPrimitiveTypeE.Entity:
                return(SoapEntity.Parse(value));
            }
            if (code != InternalPrimitiveTypeE.Invalid)
            {
                return(Convert.ChangeType(value, ToTypeCode(code), CultureInfo.InvariantCulture));
            }
            return(value);
        }
Beispiel #23
0
        internal void Write(InternalElementTypeE use, string name, AttributeList attrList, string value, bool isNameEscape, bool isValueEscape)
        {
            string s = name;

            if (isNameEscape)
            {
                s = this.NameEscape(name);
            }
            if (use == InternalElementTypeE.ObjectEnd)
            {
                this.instanceIndent--;
            }
            this.InternalWrite("<");
            if (use == InternalElementTypeE.ObjectEnd)
            {
                this.InternalWrite("/");
            }
            this.InternalWrite(s);
            this.WriteAttributeList(attrList);
            switch (use)
            {
            case InternalElementTypeE.ObjectBegin:
                this.InternalWrite(">");
                this.instanceIndent++;
                break;

            case InternalElementTypeE.ObjectEnd:
                this.InternalWrite(">");
                break;

            case InternalElementTypeE.Member:
                if (value != null)
                {
                    this.InternalWrite(">");
                    if (isValueEscape)
                    {
                        this.InternalWrite(this.Escape(value));
                    }
                    else
                    {
                        this.InternalWrite(value);
                    }
                    this.InternalWrite("</");
                    this.InternalWrite(s);
                    this.InternalWrite(">");
                    break;
                }
                this.InternalWrite("/>");
                break;

            default:
                throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_UseCode"), new object[] { use.ToString() }));
            }
            this.EmitLine();
        }
Beispiel #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();
            }
        }
 internal Assembly GetAssembly(ObjectReader objectReader)
 {
     if (this.assembly == null)
     {
         this.assembly = objectReader.LoadAssemblyFromString(this.assemblyString);
         if (this.assembly == null)
         {
             throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_AssemblyString"), new object[] { this.assemblyString }));
         }
     }
     return(this.assembly);
 }
 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();
         }
     }
 }