Esempio n. 1
0
 public static void Deserialise(this List<Link> links, JsonReader reader)
 {
     if (reader.Read() && reader.State == TJsonReaderState.Array)
     {
         Link link = null;
         while (reader.Read() && reader.State != TJsonReaderState.EndArray)
         {
             switch (reader.State)
             {
                 case TJsonReaderState.Object:
                     link = new Link();
                     links.Add(link);
                     break;
                 case TJsonReaderState.Member:
                     string attribute = reader.Text;
                     reader.Read();
                     if (string.Compare(attribute, "rel", true) == 0)
                         link.rel = reader.Text;
                     else if (string.Compare(attribute, "href", true) == 0)
                         link.href = reader.Text;
                     else
                         throw new NotSupportedException("Unsupported attribute: " + attribute);
                     break;
                 default:
                     break;
             }
         }
     }
 }
Esempio n. 2
0
 public static void Deserialise(this List<Link> links, XmlReader reader)
 {
     if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("Links"))
     {
         while (reader.Read() && reader.NodeType == XmlNodeType.Element && reader.Name.Equals("Link"))
         {
             Link link = new Link();
             link.rel = reader.GetAttribute("rel");
             link.href = reader.GetAttribute("href");
             links.Add(link);
         }
     }
 }