Skip to content

Instantly share code, notes, and snippets.

@bhameyie
Created May 1, 2017 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhameyie/d43043b553576259de4b4f19705bb77f to your computer and use it in GitHub Desktop.
Save bhameyie/d43043b553576259de4b4f19705bb77f to your computer and use it in GitHub Desktop.
Sample description of HAL extension idea
public enum LinkKind
{
Fetch,
Save,
Update
}
public enum Restrictions
{
Required,
Optional
}
public class ActionableLink
{
public string Href { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public LinkKind Kind { get; set; }
public string Name { get; set; }
}
public class PresentableField
{
public PresentableField()
{
Restrictions = new Restrictions[0];
}
[JsonProperty(ItemConverterType = typeof(StringEnumConverter))]
public IEnumerable<Restrictions> Restrictions { get; set; }
public string BoundTo { get; set; }
public bool Editable { get; set; }
public string Name { get; set; }
}
public class Presentable
{
public Presentable()
{
Fields = new PresentableField[0];
}
public IEnumerable<PresentableField> Fields { get; set; }
public string ActionBoundTo { get; set; }
}
public class Metadata
{
public string ObjectName { get; set; }
public string Description { get; set; }
}
public abstract class ExtendedModel
{
public ExtendedModel()
{
Links = new Dictionary<string,IEnumerable<ActionableLink>>();
}
[JsonPropertyAttribute("_links")]
public Dictionary<string,IEnumerable<ActionableLink>> Links { get; set; }
[JsonPropertyAttribute("_presentable")]
public Presentable Presentable { get; set; }
[JsonPropertyAttribute("_metadata")]
public Metadata Metadata { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment