{
// ...
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta1",
"Microsoft.AspNet.Mvc": "6.0.0-beta1",
"Microsoft.AspNet.Owin": "1.0.0-beta1",
"Microsoft.Owin": "3.0.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
using NLog; | |
using System; | |
using System.Threading.Tasks; | |
using System.Web.Hosting; | |
namespace Web.Models | |
{ | |
/// <summary> | |
/// Static class for running background tasks in IIS. | |
/// Any spawned threads are registered properly with IIS |
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 BackgroundService : IRegisteredObject | |
{ | |
public static void Start(Action action, TimeSpan interval) | |
{ | |
var backgroundService = new BackgroundService(interval, action); | |
HostingEnvironment.RegisterObject(backgroundService); | |
} | |
private Timer timer; |
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('autosaveExample', []) | |
.directive("Autosaved", ["$timeout", function($timeout) { | |
"use strict"; | |
return { | |
link: function(scope, element, attrs) { | |
var autosave = function() { | |
$timeout(function() { | |
var form = scope[element.attr("name")]; | |
if (form.$dirty) { |
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('saveBeforeExitExample', []) | |
.directive("saveBeforeExit", ["notificationService", function(notificationService) { | |
"use strict"; | |
return { | |
link: function(scope, element, attrs) { | |
window.onbeforeunload = function(){ | |
if (element.hasClass("ng-dirty")) { | |
element.submit(); | |
} |
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.Diagnostics; | |
using System.IO; | |
namespace kmonitor | |
{ | |
class Program | |
{ | |
private static DateTime _lastRead = DateTime.MinValue; |
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 string GetVirtualPath(VirtualPathContext context) | |
{ | |
foreach (var matcherParameter in _matcher.Template.Parameters) | |
{ | |
context.Values.Remove(matcherParameter.Name); // make sure none of the domain-placeholders are appended as query string parameters | |
} | |
return _innerRoute.GetVirtualPath(context); | |
} |
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 BulkInsert<T>(string connection, string tableName, IList<T> list, string[] propsToSkip) | |
{ | |
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock)) | |
{ | |
bulkCopy.BatchSize = list.Count; | |
bulkCopy.DestinationTableName = tableName; | |
var table = new DataTable(); | |
var props = TypeDescriptor.GetProperties(typeof(T)) | |
//Dirty hack to make sure we only have system data types |
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 () { | |
'use strict'; | |
angular.module('app') | |
.factory('Storage', [function () { | |
var fn = {}; | |
fn.has = function (key) { | |
var value = window.localStorage.getItem(key); | |
return !!value; | |
} |
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 AutofacConfig | |
{ | |
public static void Configure() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterType<ApplicationDbContext>().AsSelf().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationUserStore>().As<IUserStore<PortalUser>>().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationUserManager>().AsSelf().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationSignInManager>().AsSelf().InstancePerLifetimeScope(); |