Serialize() public méthode

public Serialize ( ) : byte[]
Résultat byte[]
Exemple #1
0
 public static void AddImageAttachment(UnsavedRevision rev, string name, Image img)
 {
     if (img == null) {
         if (rev.AttachmentNames.Contains (name)) {
             rev.RemoveAttachment (name);
         }
     } else {
         rev.SetAttachment (name, "image/png", img.Serialize());
     }
 }
Exemple #2
0
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     if (value is Time)
     {
         Time time = value as Time;
         if (time != null)
         {
             writer.WriteValue(time.MSeconds);
         }
     }
     else if (value is Color)
     {
         Color color = value as Color;
         if (color != null)
         {
             writer.WriteValue(String.Format("#{0}{1}{2}{3}",
                                             color.R.ToString("X2"),
                                             color.G.ToString("X2"),
                                             color.B.ToString("X2"),
                                             color.A.ToString("X2")));
         }
     }
     else if (value is Image)
     {
         Image image = value as Image;
         if (image != null)
         {
             writer.WriteValue(image.Serialize());
         }
     }
     else if (value is HotKey)
     {
         HotKey hotkey = value as HotKey;
         if (hotkey != null)
         {
             writer.WriteValue(String.Format("{0} {1}", hotkey.Key, hotkey.Modifier));
         }
     }
     else if (value is Point)
     {
         Point p = value as Point;
         if (p != null)
         {
             writer.WriteValue(String.Format("{0} {1}",
                                             p.X.ToString(NumberFormatInfo.InvariantInfo),
                                             p.Y.ToString(NumberFormatInfo.InvariantInfo)));
         }
     }
 }