Example #1
0
 internal static object DeserializeXmlDocument(InternalDeserializer deserializer)
 {
     object obj2;
     string xmlContents = deserializer.ReadDecodedElementString("XD");
     try
     {
         int? maxCharactersInDocument = null;
         if (deserializer._context.MaximumAllowedMemory.HasValue)
         {
             maxCharactersInDocument = new int?(deserializer._context.MaximumAllowedMemory.Value / 2);
         }
         XmlDocument document = LoadUnsafeXmlDocument(xmlContents, true, maxCharactersInDocument);
         deserializer._context.LogExtraMemoryUsage((xmlContents.Length - document.OuterXml.Length) * 2);
         obj2 = document;
     }
     catch (XmlException exception)
     {
         throw deserializer.NewXmlException(Serialization.InvalidPrimitiveType, exception, new object[] { typeof(XmlDocument).FullName });
     }
     return obj2;
 }
Example #2
0
 internal static object DeserializeUri(InternalDeserializer deserializer)
 {
     object obj2;
     try
     {
         obj2 = new Uri(deserializer.ReadDecodedElementString("URI"), UriKind.RelativeOrAbsolute);
     }
     catch (UriFormatException exception)
     {
         throw deserializer.NewXmlException(Serialization.InvalidPrimitiveType, exception, new object[] { typeof(Uri).FullName });
     }
     return obj2;
 }
Example #3
0
 internal static object DeserializeScriptBlock(InternalDeserializer deserializer)
 {
     string script = deserializer.ReadDecodedElementString("SBK");
     if (DeserializationOptions.DeserializeScriptBlocks == (deserializer._context.options & DeserializationOptions.DeserializeScriptBlocks))
     {
         return ScriptBlock.Create(script);
     }
     return script;
 }
Example #4
0
 internal static object DeserializeString(InternalDeserializer deserializer)
 {
     return deserializer.ReadDecodedElementString("S");
 }
Example #5
0
 internal static object DeserializeProgressRecord(InternalDeserializer deserializer)
 {
     ProgressRecordType type;
     object obj3;
     deserializer.ReadStartElement("PR");
     string activity = null;
     string str2 = null;
     string str3 = null;
     string statusDescription = null;
     int activityId = 0;
     int num2 = 0;
     int num3 = 0;
     int num4 = 0;
     Exception innerException = null;
     try
     {
         activity = deserializer.ReadDecodedElementString("AV");
         activityId = int.Parse(deserializer.ReadDecodedElementString("AI"), CultureInfo.InvariantCulture);
         object obj2 = deserializer.ReadOneObject();
         str2 = (obj2 == null) ? null : obj2.ToString();
         num2 = int.Parse(deserializer.ReadDecodedElementString("PI"), CultureInfo.InvariantCulture);
         num3 = int.Parse(deserializer.ReadDecodedElementString("PC"), CultureInfo.InvariantCulture);
         str3 = deserializer.ReadDecodedElementString("T");
         num4 = int.Parse(deserializer.ReadDecodedElementString("SR"), CultureInfo.InvariantCulture);
         statusDescription = deserializer.ReadDecodedElementString("SD");
     }
     catch (FormatException exception2)
     {
         innerException = exception2;
     }
     catch (OverflowException exception3)
     {
         innerException = exception3;
     }
     if (innerException != null)
     {
         throw deserializer.NewXmlException(Serialization.InvalidPrimitiveType, innerException, new object[] { typeof(ulong).FullName });
     }
     deserializer.ReadEndElement();
     try
     {
         type = (ProgressRecordType) Enum.Parse(typeof(ProgressRecordType), str3, true);
     }
     catch (ArgumentException exception4)
     {
         throw deserializer.NewXmlException(Serialization.InvalidPrimitiveType, exception4, new object[] { typeof(ProgressRecord).FullName });
     }
     try
     {
         ProgressRecord record = new ProgressRecord(activityId, activity, statusDescription);
         if (!string.IsNullOrEmpty(str2))
         {
             record.CurrentOperation = str2;
         }
         record.ParentActivityId = num2;
         record.PercentComplete = num3;
         record.RecordType = type;
         record.SecondsRemaining = num4;
         obj3 = record;
     }
     catch (ArgumentException exception5)
     {
         throw deserializer.NewXmlException(Serialization.InvalidPrimitiveType, exception5, new object[] { typeof(ProgressRecord).FullName });
     }
     return obj3;
 }