This file contains 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
public class OrderMediaTypeFormatterJson : MediaTypeFormatter | |
{ | |
public OrderMediaTypeFormatter() { | |
SupportedMediaTypes.Add( | |
new MediaTypeHeaderValue("application/contoso.orders+json") | |
); | |
} | |
public override object OnWriteToStream(Type type, object value, System.IO.Stream stream, HttpContentHeaders contentHeaders, System.Net.TransportContext context) |
This file contains 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
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<table border="1"> | |
<tr> | |
<td>ID</td> | |
<td>Name</td> | |
<td>Status</td> |
This file contains 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
public class OrderLinkHandler : HttpOperationHandler<ILinkable<Order>,ILinkable<Order>> | |
{ | |
public ILinkable<Order> OnHandle(ILinkable<Order> linkedOrder) { | |
if (linkedOrder.Instance.State == OrderStates.Created) { | |
linkedOrder.Links.Add(OrderLinks.Approval, | |
GetApprovalUri(order.ID)); | |
} | |
//other state logic here | |
return linkedOrder; |
This file contains 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
pubic class OrderApi | |
{ | |
[WebGet(UriTemplate="{id}")] | |
public XmlDocument Get(int id) { | |
var order = //get the order | |
var document = //create an XmlDocument for the order | |
return document; | |
} | |
} |
This file contains 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
config.Formatters.XmlFormatter.SupportedMediaTypes.Add(new MediaTypeMapping("application/vnd-contoso.orders.xml")); |
This file contains 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
<?xml version="1.0" encoding="utf-8" ?> | |
<Root> | |
<Contacts href="."> | |
<Contact href="."> | |
<Name>Mike Amundsen</Name> | |
<Address>123 Any Street</Address> | |
<City>Erlanger</City> | |
<State>Kentucky</State> | |
<Zip>41018</Zip> | |
<Email>mca@mamund.com</Email> |
This file contains 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
public interface ILinkable<T> { | |
T Instance {get;} | |
IList<Link> Links {get;} | |
} | |
public interface ILinkableCollection<T> : IList<ILinkable<T>> { | |
IList<Link> Links {get;} | |
void Add(string name, Uri uri, string rel=""); | |
} |
This file contains 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
public interface IUriService { | |
string OrdersBaseUri {get;} | |
string InventoryBaseUri {get;set;} | |
string UspsBaseUri {get;set;} | |
} |
This file contains 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 serviceBusService = azure.createServiceBusService(); | |
serviceBusService.createQueueIfNotExists('taskqueue', function(error, created){ | |
if(!created){ | |
// Queue exists | |
} | |
}); |
This file contains 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 serviceBusService = azure.createServiceBusService(); | |
serviceBusService.sendTopicMessage('taskdiscussion', 'Hello world!', function(error){ | |
if(!error){ | |
// Message sent | |
} | |
}); |