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
private static void SetJsonSerializerDefaults() | |
{ | |
// I set the default JSON setting to provide camel-cased properties | |
JsonConvert.DefaultSettings = () => new JsonSerializerSettings() | |
{ | |
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, | |
ContractResolver = new CamelCasePropertyNamesContractResolver() | |
}; | |
// I set the web API serializer for JSON to use JsonConverts default settings |
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
private _getErrorMessage(jqXHR: JQueryXHR, textStatus, errorThrown): string { | |
var message = textStatus + ' ' + errorThrown; | |
var error = <any>$.parseJSON(jqXHR.responseText); | |
if (error) { | |
message = error.Message; | |
if (error.ExceptionMessage) { | |
message += error.ExceptionMessage; | |
} | |
} |
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
// Sometimes the compiler will try to statically type-check when you don't want it to. | |
// TODO: I need to get a better example in here. | |
// This extension method to object makes the static type checker give up through the use of a generic method that does the casting. | |
public static T CastAs<T>(this object value) | |
{ | |
return (T)value; | |
} |
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
WebRequestHandler handler = new WebRequestHandler() | |
{ | |
UseProxy = true, | |
}; | |
var client = new HttpClient(handler); | |
client.BaseAddress = new Uri("https://api.github.com/"); | |
// You should set the version so that GitHub knows what API you area calling | |
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json")); |
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
// Note: Install WebEssentials for VisualStudio 2012 | |
// Add the TypeScript properties to the debug & release compile groups | |
// For example: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
<TypeScriptTarget>ES5</TypeScriptTarget> | |
<TypeScriptRemoveComments>false</TypeScriptRemoveComments> | |
<TypeScriptSourceMap>true</TypeScriptSourceMap> | |
<TypeScriptModuleKind>AMD</TypeScriptModuleKind> |
NewerOlder