Skip to content

Instantly share code, notes, and snippets.

@grumpydev
grumpydev / INancyOwinStartup.cs
Last active December 22, 2015 17:59
Nancy asp.net hosting katana startup test
namespace AutoStartupTest
{
using Owin;
public interface INancyOwinStartup
{
void Configuration(IAppBuilder builder);
}
}
public class TestModule : Nancy.NancyModule
{
public TestModule()
{
Get["/"] = _ =>
{
return "I am sync!";
};
Get["/async"] = async _ =>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<add extension=".cshtml" type="Nancy.ViewEngines.Razor.BuildProviders.NancyCSharpRazorBuildProvider, Nancy.ViewEngines.Razor.BuildProviders" />
<add extension=".vbhtml" type="Nancy.ViewEngines.Razor.BuildProviders.NancyVisualBasicRazorBuildProvider, Nancy.ViewEngines.Razor.BuildProviders" />
@grumpydev
grumpydev / Pluralizer.cs
Created April 19, 2013 14:34
Very simple pluralizer with the potential to handle multiple languages.
namespace ConsoleApplication2
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
/// <summary>
/// Simplistic pluraliser
/// </summary>
if (!this.stream.CanSeek)
{
var tcs = new TaskCompletionSource<Stream>();
var buffer =
new MemoryStream((int)this.stream.Length);
this.stream.CopyTo(buffer, (source, destination, ex) =>
{
if (ex != null)
{
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{904E3B5F-F4E8-44DD-91E9-B7674DBBC84D}</ProjectGuid>
@grumpydev
grumpydev / gist:5205193
Created March 20, 2013 14:44
Test Failure
System.NotSupportedException
Unable to discover CLR Type for model by the name of Nancy.ViewEngines.Razor.Tests.Models.Person.
Try using a fully qualified type name and ensure that the assembly is added to the configuration file.
AppDomain Assemblies:
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
xunit, Version=1.9.0.1566, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
Nancy.ViewEngines.Razor.Tests, Version=0.16.1.0, Culture=neutral, PublicKeyToken=null
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
namespace Nancy.Demo.Async
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class MainModule : NancyModule
{
public MainModule()
{
namespace NancyKatana
{
using System;
using System.Threading.Tasks;
using Nancy;
using NancyKatana.Models;
public class WhyDoIAlwaysCallTheseThingsMainModule : NancyModule
@grumpydev
grumpydev / test.cs
Last active December 12, 2015 10:48
Mono TypeConverter bug - always returns "true" for IsValid for int types
[beep@pinky monotest]$ mono test.exe 12
Converting 12
Converted reported IsValid as True
Conversion successful 12
[beep@pinky monotest]$ mono test.exe fred
Converting fred
Converted reported IsValid as True
Conversion failed System.Exception: fred is not a valid value for Int32. ---> System.FormatException: Input string was not in the correct format
at System.Int32.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
at System.ComponentModel.Int32Converter.ConvertFromString (System.String value, System.Globalization.NumberFormatInfo format) [0x00000] in <filename unknown>:0