Skip to content

Instantly share code, notes, and snippets.

@weitzhandler
weitzhandler / DomainTemplateRoute.cs
Last active August 29, 2015 14:25 — forked from maartenba/DomainTemplateRoute - GetVirtualPath
ASP.NET MVC 6 / ASP.NET 5 Domain Routing + Tenant Middleware
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Routing.Template;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
namespace Multitenancy.Services
@weitzhandler
weitzhandler / Tenant.cs
Last active March 20, 2016 20:28
Microsoft.AspNet.EntityFramework.Identity.Multitenant
using Microsoft.AspNet.Identity.EntityFramework.Tenant;
using Microsoft.AspNet.Routing;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity.EntityFramework.Tenant
namespace ConsoleApplication1
{
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;
class Program
{
static void Main(string[] args)
@weitzhandler
weitzhandler / OAuthHttpClient
Created November 2, 2015 02:58
A HttpClient that handles bearer tokens
using Microsoft.Owin.Security.OAuth;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net.Http
{
using System.ServiceModel.Channels;
using System.Threading.Tasks;
namespace System.ServiceModel
{
public class ClientProxy<TClient, TChannel> : IDisposable
where TClient : ClientBase<TChannel>
where TChannel : class
{
public TClient Client { get; private set; }
@weitzhandler
weitzhandler / DisplayExtension.cs
Last active May 7, 2017 05:55
Xamarin DisplayExtension - Xaml extension that extracts field description
using System.Reflection;
namespace Xamarin.Forms
{
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Xamarin.Forms.Xaml;
public class DisplayExtension : IMarkupExtension<string>
<RelativeLayout HeightRequest="60">
<ListView Rotation="270" ItemsSource="{Binding RespondersList}" RowHeight="60" SeparatorVisibility="None"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5, Constant=-30}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=-0.5, Constant=30}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=Constant, Constant=60}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Rotation="90" Padding="1" TranslationX="60">
@weitzhandler
weitzhandler / AutoCompleteView.cs
Last active October 27, 2018 13:43
Xamarin.Forms AutoCompleteView
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Windows.Input;
namespace Xamarin.Forms
@weitzhandler
weitzhandler / MultiDataTemplateSelector.cs
Created May 10, 2017 22:36
Xamarin DataTemplateSelector TargetType
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
namespace Xamarin.Forms
{
[ContentProperty(nameof(Templates))]
@weitzhandler
weitzhandler / PropertyFilterResolver.cs
Last active May 21, 2017 13:02
Json.NET property map filter resolver
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace Newtonsoft.Json.Serialization
{
public class PropertyFilterResolver : DefaultContractResolver
{