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
/** | |
* Example of using an angular provider to build an api service. | |
* @author Jeremy Elbourn ([email protected]) | |
*/ | |
/** Namespace for the application. */ | |
var app = {}; | |
/******************************************************************************/ |
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
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) { | |
$httpProvider.responseInterceptors.push([ | |
'$q', '$templateCache', 'activeProfile', | |
function($q, $templateCache, activeProfile) { | |
// Keep track which HTML templates have already been modified. | |
var modifiedTemplates = {}; | |
// Tests if there are any keep/omit attributes. | |
var HAS_FLAGS_EXP = /data-(keep|omit)/; |
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
app.directive('infiniteScroll', [ | |
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) { | |
return { | |
link: function(scope, elem, attrs) { | |
var checkWhenEnabled, handler, scrollDistance, scrollEnabled; | |
$window = angular.element($window); | |
elem.css('overflow-y', 'scroll'); | |
elem.css('overflow-x', 'hidden'); | |
elem.css('height', 'inherit'); | |
scrollDistance = 0; |
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
// Intercepting HTTP calls with AngularJS. | |
angular.module('MyApp', []) | |
.config(function ($provide, $httpProvider) { | |
// Intercept http calls. | |
$provide.factory('MyHttpInterceptor', function ($q) { | |
return { | |
// On request success | |
request: function (config) { | |
// console.log(config); // Contains the data about the request before it is sent. |
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 FileContent : HttpContent | |
{ | |
private const int DefaultBufferSize = 1024 * 64; | |
private readonly string _fileName; | |
private readonly FileInfo _fileInfo; | |
public FileContent(string fileName, MediaTypeHeaderValue contentType = null) | |
{ | |
Headers.ContentType = contentType ?? new MediaTypeHeaderValue("application/octet-stream"); |
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 ImageContent : HttpContent | |
{ | |
private Image _image; | |
public ImageContent(Image image, MediaTypeHeaderValue mediatype) | |
{ | |
_image = image; | |
Headers.ContentType = mediatype; | |
} |
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 EmbeddedContent : HttpContent | |
{ | |
private readonly Stream _Stream; | |
public EmbeddedContent(Type locatorType, string filename, MediaTypeHeaderValue contentType = null) | |
{ | |
Headers.ContentType = contentType ?? new MediaTypeHeaderValue("application/octet-stream"); |
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
// Bootstrap is used for visual effects | |
/* | |
HTML | |
<ng-upload ng-model="file"></ng-upload> | |
<ng-upload ng-model="Object.file"></ng-upload> | |
*/ | |
var directives = { | |
ngUpload: function () { |
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 Microsoft.Owin.Security; | |
using Microsoft.Owin.Security.Cookies; | |
using Microsoft.Owin.Security.DataHandler; | |
using System; | |
using System.Collections.Concurrent; | |
using System.ComponentModel.DataAnnotations; | |
using System.Data.Entity; | |
using System.Data.Entity.ModelConfiguration.Conventions; | |
using System.Linq; | |
using System.Threading; |
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
private async Task<FacebookUserViewModel> VerifyFacebookAccessToken(string accessToken) | |
{ | |
FacebookUserViewModel fbUser = null; | |
var path = "https://graph.facebook.com/me?access_token=" + accessToken; | |
var client = new HttpClient(); | |
var uri = new Uri(path); | |
var response = await client.GetAsync(uri); | |
if (response.IsSuccessStatusCode) | |
{ | |
var content = await response.Content.ReadAsStringAsync(); |