Beispiel #1
0
 // Token: 0x060001E8 RID: 488 RVA: 0x0000752C File Offset: 0x0000572C
 private static void compose(object value, XmlWriter writer)
 {
     if (value == null || value is string)
     {
         writer.WriteElementString("string", value as string);
     }
     else if (value is int || value is long)
     {
         string localName = "integer";
         int    num       = (int)value;
         writer.WriteElementString(localName, num.ToString(NumberFormatInfo.InvariantInfo));
     }
     else if (value is Dictionary <string, object> || value.GetType().ToString().StartsWith("System.Collections.Generic.Dictionary`2[System.String"))
     {
         Dictionary <string, object> dictionary = value as Dictionary <string, object>;
         if (dictionary == null)
         {
             dictionary = new Dictionary <string, object>();
             IDictionary dictionary2 = (IDictionary)value;
             try
             {
                 foreach (object obj in dictionary2.Keys)
                 {
                     object objectValue = RuntimeHelpers.GetObjectValue(obj);
                     dictionary.Add(objectValue.ToString(), RuntimeHelpers.GetObjectValue(dictionary2[RuntimeHelpers.GetObjectValue(objectValue)]));
                 }
             }
             finally
             {
                 IEnumerator enumerator;
                 if (enumerator is IDisposable)
                 {
                     (enumerator as IDisposable).Dispose();
                 }
             }
         }
         Plist.writeDictionaryValues(dictionary, writer);
     }
     else if (value is List <object> )
     {
         Plist.composeArray((List <object>)value, writer);
     }
     else if (value is byte[])
     {
         writer.WriteElementString("data", Convert.ToBase64String((byte[])value));
     }
     else if (value is float || value is double)
     {
         string localName2 = "real";
         double num2       = (double)value;
         writer.WriteElementString(localName2, num2.ToString(NumberFormatInfo.InvariantInfo));
     }
     else if (value is DateTime)
     {
         DateTime value2 = (DateTime)value;
         string   value3 = XmlConvert.ToString(value2, XmlDateTimeSerializationMode.Utc);
         writer.WriteElementString("date", value3);
     }
     else
     {
         if (!(value is bool))
         {
             throw new Exception(string.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
         }
         writer.WriteElementString(value.ToString().ToLower(), "");
     }
 }