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 serviceBusService = azure.createServiceBusService(), | |
topic = 'taskdiscussion', | |
subscription = 'client1'; | |
serviceBusService.createSubscription(topic, subscription, function(error1){ | |
if(!error1){ | |
// Subscription created | |
serviceBusService.receiveSubscriptionMessage(topic, subscription, function(error2, serverMessage){ | |
if(!error2){ |
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
git fetch upstream | |
git reset --hard upstream/master |
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
//generic formatter which takes in a model and transforms it to something specific for the media type | |
//StrategyFormatter is a generic formatter that you derive from to create specific ones. You override the formatter methods to write the response. | |
public interface IFormatterStrategy<TOutput> { | |
TOutput Transform(object model); | |
} | |
//loops through all the formatter strategies and asks them to handle the model | |
public abstract class StrategyFormatter<TOutput> : MediaTypeFormatter { | |
public IEnumerable<IStrategyFormatter<TOutput>> Strategies {public get;private set;} |
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
//this does not work because exists does not accept a standard callback | |
function createRequiredFilesIfNotPresent(_) { | |
var baseFolder = process.cwd(); | |
var exists = path.exists(baseFolder + "/server.js"); | |
log.info(exists); | |
} | |
//using a wrapper function however works. Log entries added for sequence. |
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
public class AutofacApiDependencyResolver : AutofacDependencyScope, IDependencyResolver | |
{ | |
private readonly ILifetimeScope _container; | |
public AutofacApiDependencyResolver(ILifetimeScope container) : base(container) | |
{ | |
_container = container; | |
} | |
public IDependencyScope BeginScope() |
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
public interface IFormsAuthentication | |
{ | |
void SetAuthCookie(string userName, bool createPersistantCookie, string cookiePath); | |
void SetAuthCookie(string userName, bool createPersistentCookie); | |
} | |
public class FormsAuthenticationWrapper : IFormsAuthentication | |
{ | |
public void SetAuthCookie(string userName, bool createPersistantCookie, string cookiePath) |
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
MenuContext.cs | |
public class MenuContext : DbContext | |
{ | |
public DbSet<MenuItem> MenuItems { get; set; } | |
public DbSet<Review> Reviews { get; set; } | |
} | |
MenuController.cs |
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
public class CustomerController : ApiController { | |
private ICustomerContext repo; | |
public CustomerController(ICustomerContext repo) { | |
this.repo = repo; | |
} | |
public Customer Get(int id) { | |
var customer = repo.Customers.SingleOrDefault(c=>c.CustomerID == id); | |
if (customer == null) { |
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
public class CustomerController : ApiController { | |
private ICustomerContext repo; | |
public CustomerController(ICustomerContext repo) { | |
this.repo = repo; | |
} | |
public HttpResponseMessage Post(Customer customer) { | |
repo.Add(customer); | |
repo.SaveChanges(); |
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
//child_process.js | |
var util = require('util'), | |
child_process = require('child_process'), | |
child, | |
cmd; | |
var os = require('os'); | |
exec(); |