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 override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContentHeaders contentHeaders, TransportContext transportContext) { | |
string callback; | |
if (isJsonpRequest(request, out callback)) { | |
var writer = new StreamWriter(stream); | |
writer.Write(callback + "("); | |
writer.Flush(); | |
return base.WriteToStreamAsync(type, value, stream, contentHeaders, transportContext).ContinueWith(_ => { |
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
static void Main(string[] args) { | |
var client = new OAuthHttpClient(_consumerKey, _consumerSecret, _token, _tokenSecret); | |
var response = client.GetAsync("http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=tourismgeek&count=5").Result; | |
response.EnsureSuccessStatusCode(); | |
var result = response.Content.ReadAsAsync<JToken>().Result; | |
foreach (var status in result) | |
Console.WriteLine(status["text"] + Environment.NewLine); |
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.Collections.Generic; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Security.Cryptography; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using WebAPIDoodle.Http.Entity; |
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
function calculateToastrPosition() { | |
var windowWidth = $(window).width(), | |
toastMsgWidth = 300; | |
var leftOffset = (windowWidth - toastMsgWidth) / 2; | |
$('<style>').text(".toast-top-center { top: 10px; left: " + leftOffset + "px; }").appendTo("head"); | |
} |
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
//http://stackoverflow.com/questions/1047218/benchmarking-small-code-samples-in-c-can-this-implementation-be-improved | |
static void Profile(string description, int iterations, Action func) { | |
// clean up | |
GC.Collect(); | |
GC.WaitForPendingFinalizers(); | |
GC.Collect(); | |
// warm up |
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 static void Configure(HttpConfiguration config) { | |
config.Formatters.Remove(config.Formatters.XmlFormatter); | |
config.Formatters.Remove(config.Formatters.FormUrlEncodedFormatter); | |
// From DefaultContentNegotiator class: | |
// If ExcludeMatchOnTypeOnly is true then we don't match on type only which means | |
// that we return null if we can't match on anything in the request. This is useful | |
// for generating 406 (Not Acceptable) status codes. | |
config.Services.Replace( |
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
{ | |
"Message": "The request is invalid.", | |
"ModelState":{ | |
"blogPost": [ | |
"Required property 'Content' not found in JSON. Path '', line 1, position 44.", | |
"Required property 'IsApproved' not found in JSON. Path '', line 1, position 44." | |
], | |
"blogPost.Content": [ | |
"The Content field is required." | |
], |
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.ComponentModel; | |
namespace AnonymousTypePropertyDescriptors { | |
class Program { | |
static void Main(string[] args) { | |
var values = new { |
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
{ | |
"PageIndex": 1, | |
"PageSize": 2, | |
"TotalCount": 91, | |
"TotalPageCount": 46, | |
"HasNextPage": true, | |
"HasPreviousPage": false, | |
"Dtos": [ | |
{ | |
"Key": "e351b1f4-cdee-e111-be77-e89d871b012b", |
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
DECLARE @p__linq__0 AS NVARCHAR(10) = 'en'; | |
SELECT TOP (10) | |
[Project1].[Order] AS [Order], | |
[Project1].[Key] AS [Key], | |
[Project1].[LanguageKey] AS [LanguageKey], | |
[Project1].[SecondaryKey] AS [SecondaryKey], | |
[Project1].[Title] AS [Title], | |
[Project1].[BriefInfo] AS [BriefInfo], | |
[Project1].[Content] AS [Content], | |
[Project1].[ImagePath] AS [ImagePath], |