Web API Tutorials Part 4 : Controller Attribute Based Routing

Web API offers some powerful routing behaviour.  Let’s look at how we can use this in our app to avoid needing a new Controller for every Translation we wish to offer (again, ignore the fact our sample is likely only ever to require two way!).

We currently have a single AlphabetToMorseController with our old ITranslator implementation.  In the previous tutorial we abstracted our service into an extensible dictionary, this should allow us to take our Translator Key as a routing parameter and our string to translate as a parameter in the URI on our API.

Outcome

By the end of the post we’ll have refactored the existing AlphabetToMorseController to a generic TranslatorController, with our ITranslatorService being injected.  The Key will be provided through a Web API Route, and the Get Requested to the Controller will return a collection of available Translators. Continue reading “Web API Tutorials Part 4 : Controller Attribute Based Routing”

Universal App Tutorials Part 13 : Custom Enum Attributes

Most applications need a settings page to allow a user to configure how they wish to use your application.  In this tutorial we’ll start to look at making the Translation Direction configurable.  We’ll shortly be adding in a Settings page, but there’s some groundwork required before we begin.

Outcome

By the end of this tutorial the Translation Direction Attribute should have a custom Display Attribute associated to it, allowing for the associated display string to be displayed on the view via a Value Converter, which will look up the display text for a given enum value. Continue reading “Universal App Tutorials Part 13 : Custom Enum Attributes”