-
Notifications
You must be signed in to change notification settings - Fork 11
Follow a link
JornWildt edited this page Mar 25, 2013
·
1 revision
using System;
using Ramone;
using Ramone.MediaTypes.Atom;
using Ramone.HyperMedia;
// Define resource type
public class Cat
{
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
public AtomLink Parent { get; set; }
}
public static class Cats
{
// URL template (relative to service root)
const string CatUrlTemplate = "/cat/{name}";
public static void GetCat()
{
// Create session pointing to service root
ISession Session = RamoneConfiguration.NewSession(new Uri("http://localhost/ramone-testserver"));
// Setup HTTP request
Request req = Session.Bind(CatUrlTemplate, new { name = "Mike" });
// Make actual request
using (var resp = req.AcceptXml().Get<Cat>())
{
Cat c = resp.Body;
Console.WriteLine("Cat with name={0} was born on={1:d}.", c.Name, c.DateOfBirth);
using (var parentResp = c.Parent.Follow(Session).AcceptXml().Get<Cat>())
{
Cat parent = parentResp.Body;
Console.WriteLine("Cat with name={0} has parent.name={1}", c.Name, parent.Name);
}
}
}
}