Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / gist:5dfb780eb8f9dd109924
Created June 25, 2014 19:10
Resolve registered types that implement a given generic interface for Autofac
var connectionTypes = _LifetimeScope
.ComponentRegistry
.Registrations
.Where(reg =>
reg.Activator
.LimitType
.GetInterfaces()
.Any(iface =>
iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(IConnectionEditorViewModel<>)
)
@dealproc
dealproc / AuthorizationProvider.js
Created July 17, 2014 15:56
The way we sent the headers to the api backend from DurandalJS
define(['amplify'], function () {
return {
BeginAuthorization: function () {
var authorizationUrl = SystemState.AuthorizationUrl,
client_id = SystemState.ClientID,
scope = SystemState.AuthScope,
response_type = "token",
redirect_uri = SystemState.AuthRedirectURI,
@dealproc
dealproc / DataGridAutomaticEditingBehavior.cs
Created July 18, 2014 15:38
WPF Datagrid - Edit on focus
namespace {Your.Namespace.Here}.Behaviors {
using System.Windows.Controls;
using System.Windows.Interactivity;
// Pulled from: http://codermonkey65.blogspot.com/2012/12/making-wpf-datagrid-keyboard-friendly.html
public class DataGridAutomaticEditingBehavior : Behavior<DataGrid> {
protected override void OnAttached() {
AssociatedObject.GotFocus += AssociatedObject_GotFocus;
base.OnAttached();
}
@dealproc
dealproc / BaseSyncTask.cs
Last active August 29, 2015 14:04
Healing SignalR Connection
namespace {YourNamespace}.ServiceBus.Tasks {
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public abstract class BaseSyncTask : ISyncTask {
protected NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
public abstract int Priority { get; }
@dealproc
dealproc / ParameterModelsModelBinder.cs
Last active August 29, 2015 14:04
Binding to a generic type through reflection.
namespace Adapt.SSRV.Web.Models {
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
public class ParameterModelsModelBinder : IModelBinder {
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) {
if (bindingContext.ModelType != typeof(ParameterModels)) {
return false;
@dealproc
dealproc / sslassignment.ps1
Created August 15, 2014 03:13
SSL Creation using NetSH
## --------------------------------------------------------------------------------------
## Input
## --------------------------------------------------------------------------------------
$webSiteName = $OctopusParameters['WebSiteName']
$bindingPort = $OctopusParameters["BindingPort"]
$bindingIpAddress = $OctopusParameters["BindingIpAddress"]
$bindingHost = $OctopusParameters["BindingHost"]
$bindingSslThumbprint = $OctopusParameters["BindingSslThumbprint"]
@dealproc
dealproc / AccountAccessor.cs
Last active August 29, 2015 14:07
NHibernateSessionSource
using NHibernate;
using NLog;
public class AccountAccessor : IAccountAccessor {
Logger Log = LogManager.GetCurrentClassLogger();
ISessionFactory _SessionFactory;
public AccountAccessor(ISessionFactory sessionFactory) {
_SessionFactory = sessionFactory;
}
@dealproc
dealproc / ThreadSafeObservableCollection.cs
Created November 24, 2014 19:25
ThreadSafeObservableCollection.cs
using System;
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows.Threading;
using Kiosk.Error;
using Kiosk.Globals;
namespace Kiosk.Gui.Types
{
[Serializable]
@dealproc
dealproc / Customer.cs
Last active August 29, 2015 14:13
Full Duplex Routing
public class Customer : HQDataModelBase {
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual string HomePhone { get; set; }
public virtual string MobilePhone { get; set; }
public virtual string BusinessPhone { get; set; }
public virtual string Email { get; set; }
public virtual Address Address { get; set; }
}
@dealproc
dealproc / DialogManager.cs
Created January 16, 2015 14:15
MahApps.Metro & Caliburn Micro DialogViewManager Implementation .. basis was from someone else, but I had to re-tool it to work the way i wanted. It seems as if full binding is working as expected as well using the CM pipeline :)
using {Product}.UX.ViewModels.Framework;
using Caliburn.Micro;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace {Product}.UX.Services {
public class DialogManager : IDialogManager {
public static readonly MetroDialogSettings dialogSettings = new MetroDialogSettings {