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 assembly = Assembly.GetCallingAssembly(); | |
var actionMethods = assembly.GetTypes() | |
// Find all non abstract classes of type Controller and whose names end with "Controller" | |
.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(TwilioController)) && x.Name.EndsWith("Controller")) | |
// Find all public methods from those controller classes | |
.SelectMany(x => x.GetMethods().Where(m => m.DeclaringType.Name == x.Name), (x, y) => new { Controller = x.Name.Substring(0, x.Name.Length - 10), Method = y.Name }); | |
foreach (var action in actionMethods) { | |
routes.MapRoute(action.Method, action.Method, new { controller = action.Controller, action = action.Method }); | |
} |
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 HomeController : TwilioController | |
{ | |
// /StartPhoneCall | |
public void StartPhoneCall() { | |
Say("Thank you for calling " + Called); | |
Say("Hello world!", 1, Voice.Man, Language.English); | |
Play("http://example.com", 1); | |
Gather(30, |
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
using System; | |
using System.Net; | |
using System.IO; | |
using System.Text; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace LongPolling | |
{ | |
class MainClass |
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
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", (msg) => { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
}); | |
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", smsSent); | |
public void smsSent(SmsMessage msg) { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
} | |
// or |
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
using System; | |
using RestSharp; | |
namespace StatsMix | |
{ | |
// Requires RestSharp | |
// http://restsharp.org | |
// http://github.com/johnsheehan/RestSharp | |
// Usage |
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
C:\dev\heroku-test\public>ssh-keygen | |
Generating public/private rsa key pair. | |
Enter file in which to save the key (//.ssh/id_rsa): | |
Could not create directory '//.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
open //.ssh/id_rsa failed: No such file or directory. | |
Saving the key failed: //.ssh/id_rsa. |
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
[TestMethod] | |
public void Can_Generate_Single_Say_With_Shortcut() | |
{ | |
var response = new TwilioResponse(); | |
response.Say("Hello world"); | |
var expected = XDocument.Parse("<Response><Say>Hello world</Say></Response>").ToString(); | |
var actual = response.ToString(); | |
Assert.AreEqual(expected, actual); |
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 EntityBase:DynamicModel { | |
public EntityBase():base("northwind") { | |
PrimaryKeyField = "Id"; | |
} | |
} | |
public class Product : EntityBase { | |
} | |
public class User : EntityBase { |
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 http = new Http("https://api.twilio.com/{version}/Accounts"); | |
http.AddUrlSegment("version", "2010-04-01"); | |
http.AddParameter("name", "value"); | |
http.Authenticate = (request) => // authenticators would just follow this contract | |
{ | |
request.AddHeader("name", "value"); | |
}; | |
http.Complete = (response, data) => | |
{ |
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
// use in webmatrix | |
@{ | |
Helper.Fetch(url: "http://example.com", method: "GET"); | |
} | |
@{ | |
Helper.Fetch(url: "http://example.com", method: HttpMethod.GET); // no intellisense or build protection | |
} | |
// regular code use, not webmatrix and not 4.0 |
OlderNewer