Skip to content

Instantly share code, notes, and snippets.

View james-dibble's full-sized avatar

James Dibble james-dibble

View GitHub Profile
@james-dibble
james-dibble / Startup.cs
Created December 23, 2014 16:31
Umbraco startup class to add routes for Syndication
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Core;
public class Startup : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
@james-dibble
james-dibble / SyndicationController.cs
Last active August 29, 2015 14:12
A basic implementation of an Umbraco SurfaceController that returns RSS feeds
using System;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Web.Mvc;
using JamesDibble.ApplicationFramework.Web.Rss;
using Umbraco.Web;
using Umbraco.Web.Mvc;
@james-dibble
james-dibble / BeforeBuildScript.ps1
Created October 19, 2014 09:59
Appveyor before build arguments to patch the csproj file so that a ClickOnce manifest's version is in sync
[xml]$projectFile = Get-Content "C:\projects\chocolateyexplorer\ChocolateyExplorer.WPF\ChocolateyExplorer.WPF.csproj"
$projectFile.Project.ChildNodes.Item(1).ApplicationVersion = "$env:APPVEYOR_BUILD_VERSION"
$projectFile.Save("C:\projects\chocolateyexplorer\ChocolateyExplorer.WPF\ChocolateyExplorer.WPF.csproj")
@james-dibble
james-dibble / AfterBuildScript.ps1
Created October 6, 2014 19:27
Appveyor after build arguments to create a versioned ClickOnce package
msbuild ChocolateyExplorer.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /t:Publish /property:ApplicationVersion="$env:APPVEYOR_BUILD_VERSION"
@james-dibble
james-dibble / clickonce.csproj
Last active August 29, 2015 14:07
ClickOnce project elements
<PublishUrl>/chocolatey-explorer/</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="SomeThirdPartyAssembly"/>
<ShimGeneration>
<Clear/>
<Add FullName="SomeThirdPartyClassThatInheritsObselete"/>
<Remove Obsolete="1"/>
</ShimGeneration>
</Fakes>
public class SomeController : Controller
{
public ActionResult GetCookie()
{
var cookie = this.Request.Cookies["CookieName"];
if(cookie == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
[TestMethod]
public async Task TestGenericOperation
{
var fakeThing = new StubIThingWithGeneric();
fakeThing.GenericOperationAsyncOf1(() => new SomeOtherThing();
var target = new TestTarget(fakeThing);
var actual = await target.DoSomething();
@james-dibble
james-dibble / RouteConfig.cs
Created May 17, 2014 12:20
Example route being added to RouteCollection
routes.Add(
new Route(
"product/{productCategory}/filter/{*filters}",
new RouteValueDictionary
{
{ "controller", "Product" },
{ "action", "Filter" }
},
new DictionaryRouteHandler<int, string>("filters")));
@james-dibble
james-dibble / DictionaryRouteHandler.cs
Last active August 29, 2015 14:01
Dictionary MVC Route Handler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
public class DictionaryRouteHandler<TKey, TValue> : MvcRouteHandler
{
private readonly string _key;