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 static HtmlDocument GetHtmlDocument(string url) | |
{ | |
var page = new HtmlDocument | |
{ | |
OptionOutputAsXml = true | |
}; | |
HtmlNode.ElementsFlags.Remove("option"); | |
// Fetch and load HTML document (default gym selected) | |
var request = (HttpWebRequest)HttpWebRequest.Create(url); |
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.IO; | |
using System.Web.Mvc; | |
using System.Web; | |
namespace Example.Web.Helpers | |
{ | |
public static class UrlHelperExtensions | |
{ | |
/// <summary> |
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 (lab, $, undefined) { | |
lab.Utils = new (function () { | |
return { | |
UpdateValidationErrors: function (viewModel, modelState) { | |
var keySeparator = new RegExp("[.\\[\\]]+"); | |
for (var key in modelState) { | |
if (!modelState[key]) { | |
continue; | |
} |
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 TypeStampedModelBinder : DefaultModelBinder | |
{ | |
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) | |
{ | |
if (typeof(ITypeStamped).IsAssignableFrom(bindingContext.ModelType)) | |
{ | |
// Handle type-stamped model | |
var prefix = bindingContext.ModelName; | |
if (bindingContext.ValueProvider.ContainsPrefix(prefix)) | |
{ |
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> | |
/// Simplifies the structure of a ModelStateDictionary instance to a "key => [ "error1", "error2", ... "errorN" ]" dictionary. | |
/// Also removes entries with no error messages. | |
/// </summary> | |
/// <param name="modelState"></param> | |
/// <returns></returns> | |
public static Dictionary<string, string[]> Simplify(this ModelStateDictionary modelState) | |
{ | |
return modelState.ToDictionary( | |
entry => entry.Key, |
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
SetValidationResult: function (viewModel, modelState) { | |
var trySetErrors = function (modelStateKey, modelStateErrors) { | |
var keySeparator = new RegExp("[.\\[\\]]+"); | |
var propertyChain = modelStateKey.split(keySeparator); | |
var currentObject = viewModel; | |
var currentPropertyName = propertyChain.shift(); | |
var targetObject = null; | |
while (currentObject && currentObject[currentPropertyName]) { |
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 (ko, undefined) { | |
ko.observable.fn.withValidation = function () { | |
var observable = this; | |
observable.Errors = ko.observableArray(); | |
observable.HasErrors = ko.computed(function () { | |
return observable.Errors().length > 0; | |
}); | |
return observable; | |
}; |
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
// Notification shims for Dynamics CRM 2011 (both pre and post UR12). | |
// The API is identical to the native (supported) notifications in | |
// Dynamics CRM 2013. Please note that calling undocumented JavaScript functions | |
// is not officially supported by Microsoft, which makes these shims | |
// "unsupported". But since the API is compatible with 2013 the upgrade path | |
// is straightforward (just remove the code completely, or leave them if you | |
// prefer - either should be fine). | |
if (typeof(Xrm.Page.ui.clearFormNotification) === "undefined") { | |
Xrm.Page.ui.clearFormNotification= function(messageId) { | |
var crmNotifications = |
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 authContext = new AuthenticationContext({ | |
// ... | |
}); | |
// Our custom asynchronous login function. Uses authContext.config.displayCall | |
// to show the Azure AD login page in a popup window, then periodically checks | |
// the popup window for the resulting hash + uses adal.js to handle it. | |
// For this to work, we need a dummy landing page to use as redirectUri. | |
// This can be an empty HTML page, but needs to have the same origin as the | |
// main window. |
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 interface IHandler<TMessage> | |
{ | |
string StateKey(TMessage message); | |
HandlerResult Handle(TMessage message, object state); | |
} | |
public class HandlerResult | |
{ | |
public object State { get; set; } | |
public IEnumerable<object> Messages { get; set; } |
OlderNewer