Created
June 20, 2011 21:49
-
-
Save darrelmiller/1036674 to your computer and use it in GitHub Desktop.
Creating the hal spec example using Hal.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hal = HalDocument.Create(new Uri("http://example.org")); | |
hal.AddNamespace("td", new Uri("http://mytodoapp.com/rels/")); | |
hal.AddLink("td:search", new Uri("/todo-list/search;{searchterm}",UriKind.Relative)); | |
hal.AddLink("td:description", new Uri("/todo-list/description", UriKind.Relative)); | |
hal.AddProperty("created_at", "2010-01-16"); | |
hal.AddProperty("updated_at", "2010-02-21"); | |
hal.AddProperty("summary", "An example list"); | |
hal.CreateResource("td:owner", new Uri("http://range14sux.com/mike")) | |
.AddProperty("name","Mike") | |
.AddProperty("age","36") | |
.AddLink("td:friend", new Uri("http://mamund.com/")) | |
.End(); | |
hal.CreateResource("td:item", new Uri("http://home.com/tasks/126"), "1") | |
.AddProperty("title", "Find Mug") | |
.AddProperty("details", "Find my mug.") | |
.AddTypedResource("td:attachment", "text/plain", | |
@"********************************** | |
PLACES MY MUG COULD BE | |
********************************** | |
- Garden | |
- Roof | |
- Zipcar | |
- Shelf") | |
.AddLink("td:next", new Uri("http://work.com/todos/make-some-tea")) | |
.End(); | |
hal.CreateResource("td:item", new Uri("http://work.com/todos/make-some-tea"), "2") | |
.AddProperty("title", "Make tea") | |
.AddProperty("details", "Mike nice tea that is green. (Gyokuro)") | |
.AddLink("td:prev", new Uri("http://home.com/tasks/126")) | |
.End(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment