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; | |
using System.Runtime.InteropServices; | |
using System.Security.Permissions; | |
using System.Security.Principal; | |
public class UserImpersonator : IDisposable | |
{ | |
[DllImport("advapi32.dll", SetLastError = true)] |
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.Dynamic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Xml; | |
using System.Xml.Linq; | |
using System.Xml.Serialization; |
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.Specialized; | |
using System.IO; | |
using System.Net; | |
using System.Text; | |
using System.Web; | |
public static class CommonExtensions | |
{ | |
public static string ToQueryString(this NameValueCollection nvc) |
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.Web.Mvc; | |
public static class UrlExtensions | |
{ | |
public static string BackAction(this UrlHelper urlHelper, string actionName) | |
{ | |
string url = null; | |
var urlReferrer = urlHelper.RequestContext.HttpContext.Request.UrlReferrer; | |
if (urlReferrer != null) | |
{ |
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
Timer = function (timerFn, delay, intervalFn, interval) { | |
/// <summary>Set a timer/timeout with Stop, Start, and Restart capability</summary> | |
/// <param name="timerFn" type="Function">Function to run after the amount of time specified by the delay parameter</param> | |
/// <param name="delay" type="Number">Amount of time to delay the timerFn</param> | |
/// <param name="intervalFn" type="Function">Function to run after the interval specified in the interval parameter</param> | |
/// <param name="interval" type="Number">Amount of time to run the intervalFn function (frequency)</param> | |
var _self = this, | |
_timerFn = timerFn, | |
_delay = delay, |
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
/// <reference path="jquery-1.8.2.js" /> | |
/// <reference path="Timer.js" /> | |
InactivityPoll = function (inactiveFn, inactiveDelay, confirmStartedFn, confirmFn, confirmDelay, intervalFn, interval, debug) { | |
/// <param name="inactiveFn" type="Function">Function to call when the inactivityDelay time has been passed</param> | |
/// <param name="inactiveDelay" type="Number">Amount of time to wait before calling the inactiveFn</param> | |
/// <param name="confirmStartedFn" type="Function">Function to call when the when the confirmDely starts counting down</param> | |
/// <param name="confirmFn" type="Function">Function to call when the confirmDelay time has been passed</param> | |
/// <param name="confirmDelay" type="Number">Amount of time to wait before calling the confirmFn</param> | |
/// <param name="intervalFn" type="Function">Function to run after the interval specified in the interval parameter</param> |
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 $saveAndExit = $('#saveAndExit'), | |
$inactivity = $('#inactivity'), | |
$saveAndExitRedirectSpan = $saveAndExit.find('.redirectTime'), | |
saveAndExitRedirectTime = $saveAndExit.data('redirecttime'), | |
saveAndExitRedirectExecutesAt = new Date().AddMilliseconds(parseInt(saveAndExitRedirectTime)), | |
inactivityInactivityTime = $inactivity.data('inactivitytime'), | |
inactivityRedirectTime = $inactivity.data('redirecttime'), | |
$inactivityRedirectSpan = $inactivity.find('.redirectTime'); |
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
/// <summary> | |
/// A base class for the singleton design pattern. | |
/// </summary> | |
/// <typeparam name="T">Class type of the singleton</typeparam> | |
public abstract class SingletonBase<T> where T : class | |
{ | |
#region Members | |
/// <summary> | |
/// Static instance. Needs to use lambda expression |
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
// fix jquery validate reset form (this is a snippet that i created a while ago | |
$.extend($.validator.prototype, | |
{ | |
optional: function (element) { | |
return !$.validator.methods.required.call(this, $.trim(element.value), element); // && "dependency-mismatch"; | |
}, | |
resetForm: function () { | |
if ($.fn.resetForm) { | |
$(this.currentForm).resetForm(); | |
// fix |
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 MvcInputExtensions = System.Web.Mvc.Html.InputExtensions; | |
public static class InputExtensions | |
{ | |
public static MvcHtmlString FileUploadFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression) | |
{ | |
return MvcInputExtensions.TextBoxFor<TModel, TProperty>(html, expression, htmlAttributes: new { type = "file" }); | |
} | |
} |
OlderNewer