Skip to content

Instantly share code, notes, and snippets.

@andygjp
andygjp / Program.cs
Created January 9, 2017 23:25
Create an enumeration using Roslyn
namespace ConsoleApplication8
{
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@andygjp
andygjp / program.cs
Created September 29, 2016 21:45
Opens the files specified and strips out the emails
namespace ExtractEmails
{
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
public class Program
{
@andygjp
andygjp / ConsoleApplication1.csproj
Created July 11, 2016 20:55
Automatically add all none generated EntityTypeConfigurations
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>
<ProjectGuid>{4B7FDFDE-3CFF-4A96-9D76-8B8E495C24DD}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
@andygjp
andygjp / ReplaceNullContentWithNotFoundAttribute
Created October 15, 2014 21:58
A workaround that will recognise when a SingleResult type does not contain any results and replace it with a 404 instead of throwing a SerializationException.
internal class ReplaceNullContentWithNotFoundAttribute : EnableQueryAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
base.OnActionExecuted(actionExecutedContext);
HttpResponseMessage httpResponseMessage = actionExecutedContext.Response;
if (httpResponseMessage.IsSuccessStatusCode && IsContentMissingValue(httpResponseMessage))
{
actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.NotFound);
@andygjp
andygjp / Create.cshtml
Created June 6, 2012 15:14
Create order sample
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<link href="@Url.Content("~/Content/themes/base/minified/jquery-ui.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout-2.1.0.js")" type="text/javascript"></script>