Skip to content

Instantly share code, notes, and snippets.

View pksorensen's full-sized avatar

Poul Kjeldager Sørensen pksorensen

View GitHub Profile
namespace Composite.WebApi
{
using Composite.Community.Blog;
using Composite.Core.WebApi;
using System;
public class BlogPostsController : C1ApiController<Entries,Guid>
@pksorensen
pksorensen / Startup.cs
Created September 5, 2013 23:19
A configuration of SignalR and WebApi in the same App.
internal class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseErrorPage();
app.Map("/signalr", map =>
{
var config = new HubConfiguration
{
using Microsoft.Owin;
using Microsoft.Owin.Logging;
using Microsoft.Owin.Security.Infrastructure;
using Owin;
namespace Composite.WindowsAzure.Management.Owin
{
public class BasicAuthenticationMiddleware : AuthenticationMiddleware<BasicAuthenticationOptions>
{
using Microsoft.Owin.Logging;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Infrastructure;
using System;
using System.Text;
using System.Threading.Tasks;
namespace Composite.WindowsAzure.Management.Owin
{
public class BasicAuthenticationHandler : AuthenticationHandler<BasicAuthenticationOptions>
@pksorensen
pksorensen / Channel9Controller.cs
Last active December 24, 2015 13:49
Asp.Net WebAPI 2.0. Route Attributes, IHttpActionResults It pulls the events from an event on channel9, like this : http://channel9.msdn.com/Events/Microsoft-Campus-Days/Microsoft-Campus-Days-2013/RSS
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Xml.Linq;
@pksorensen
pksorensen / startup.cs
Created October 7, 2013 13:29
Simple OpensHours Restriction Middleware, example of creating a simple middleware.
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(TypeScriptHTMLApp2.Startup))]
//http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection
namespace TypeScriptHTMLApp2
{
@inherits RazorFunction
@functions {
public override string FunctionDescription
{
get { return "A demo function that outputs a hello message."; }
}
[FunctionParameter(DefaultValue = "World")]
public string Name { get; set; }
@pksorensen
pksorensen / Channel9ActionResult.cs
Created October 7, 2013 16:14
simplify long types with usings
using EventCache = ConcurrentDictionary<string, KeyValuePair<DateTime, Task<List<Event>>>>;
public class Channel9ActionResult : IHttpActionResult
{
private readonly HttpRequestMessage _request;
private static Lazy<ConcurrentDictionary<string, KeyValuePair<DateTime, Task<List<Event>>>>> _cache2
= new Lazy<ConcurrentDictionary<string, KeyValuePair<DateTime, Task<List<Event>>>>>(() =>
new ConcurrentDictionary<string, KeyValuePair<DateTime, Task<List<Event>>>>());
@pksorensen
pksorensen / RazorDemoTreeDefinition.xml
Created November 6, 2013 22:28
A Composite C1 TreeDefinition File for opening a CustomUrlAction.
<?xml version="1.0" encoding="utf-8" ?>
<ElementStructure xmlns="http://www.composite.net/ns/management/trees/treemarkup/1.0" xmlns:f="http://www.composite.net/ns/function/1.0">
<ElementStructure.AutoAttachments>
<NamedParent Name="Content" Position="Top" />
</ElementStructure.AutoAttachments>
<ElementRoot>
<Children>
<Element Id="mydemo" Label="Razor Demo" Icon="pagetype-pagetype-rootfolder" OpenedIcon="pagetype-pagetype-rootfolder-open">
@pksorensen
pksorensen / mydemo.cshtml
Created November 6, 2013 23:00
A Composite C1 Razor View for the console.
@{
Layout = "~/Composite/Controls/Razor/RazorLayout.cshtml";
bool ShowPaid = true;
bool ShowShipped = false;
}
@functions
{
public string CallbackId
{