Skip to content

Instantly share code, notes, and snippets.

View chrisortman's full-sized avatar

Chris Ortman chrisortman

View GitHub Profile
@chrisortman
chrisortman / LoginForm.cs
Created February 27, 2014 16:34
Example of C# html builder
public class LoginForm : FormView
{
public LoginForm()
{
this.Action = "/login";
Method = "POST";
AutoComplete = "off";
Classes = new[] {"form-stacked"};
DefineFields<LoginModel>(f =>
@chrisortman
chrisortman / example.cs
Last active December 30, 2015 06:49
I've been doing this thing where I pass an 'output' object into methods. The things I like about this are * I can vary implementation of output objects like one for an MVC ViewModel and another for a WPF ViewModel * Keeps privates of business objects (for lack of a better term) private * When I have methods that need to return more than one thin…
public class Payment {
private int _accountID;
private int _userID;
private decimal _paymentAmount;
/* I realize this looks almost like it should be a FI, but
that would just distract from the point */
public void OnAccount(int id) {
_accountID = id;
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="My WPF UI" Height="300" Width="300">
<StackPanel Margin="5">
<StackPanel>
<Label Content="Prename:" />
<TextBox x:Name="preName" MinWidth="50"/>
</StackPanel>
<StackPanel>
<Label Content="Surename:" />
@chrisortman
chrisortman / gist:5152438
Created March 13, 2013 14:07
Example of screwy nuget behavior
(-> means references)
WebProject -> ServiceStack 3.9.32 -> ServiceStack.Text 3.9.32
Using 'Manage nuget packages for solution' I add ServiceStack to my test project and wind up with
TestProject -> ServiceStack 3.9.32 -> ServiceStack.Text 3.9.38
#WTF!!!
@chrisortman
chrisortman / gist:4046168
Created November 9, 2012 14:58
restricted xml request
[Route("/helloservice/alive")]
[Service(1,RestrictAccessTo = EndpointAttributes.Xml | EndpointAttributes.HttpGet)]
public class Alive {}
@chrisortman
chrisortman / nonminifiedjavascript.cs
Created March 12, 2012 15:54
Non minified javascript bundle
public class NonMinifyingJavascript : IBundleTransform
{
public void Process(BundleContext context, BundleResponse bundle)
{
if(bundle == null)
{
throw new ArgumentNullException("bundle");
}
context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();
@chrisortman
chrisortman / ImportedFilePathResolver.cs
Created March 8, 2012 19:48
ASP.NET Optimization Minifiers
public class ImportedFilePathResolver : IPathResolver
{
private string currentFileDirectory;
private string currentFilePath;
/// <summary>
/// Initializes a new instance of the <see cref="ImportedFilePathResolver"/> class.
/// </summary>
/// <param name="currentFilePath">The path to the currently processed file.</param>
public ImportedFilePathResolver(string currentFilePath)
@chrisortman
chrisortman / A.cs
Created February 27, 2012 22:11
IoC example
public class A {
public A() {
_b = new B();
}
}
@chrisortman
chrisortman / project file
Created February 23, 2012 17:27
Project file diff upgrading mvc3 to mvc4 beta
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
- <Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\AspMvc-3.0\System.Web.Helpers.dll</HintPath>
- <Private>False</Private>
+ <Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">^M
+ <Private>True</Private>^M
+ <HintPath>..\..\packages\AspNetWebPages.Core.2.0.20126.16343\lib\net40\System.Web.Helpers.dll</HintPath>^M
@chrisortman
chrisortman / gist:1635993
Created January 18, 2012 21:50
MSBuild output when EntityFramework installed in GAC
Primary reference "EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". (TaskId:16961)
Resolved file path is "C:\Builds\10\OSS\Current\Sources\Current\Billing\Web\packages\EntityFramework.4.1.10715.0\lib\EntityFramework.dll". (TaskId:16961)
Reference found at search path location "{HintPathFromItem}". (TaskId:16961)
For SearchPath "C:\Builds\10\OSS\Current\Sources\Current\_Dependencies". (TaskId:16961)
Considered "C:\Builds\10\OSS\Current\Sources\Current\_Dependencies\EntityFramework.dll", but it didn't exist. (TaskId:16961)
Considered "C:\Builds\10\OSS\Current\Sources\Current\_Dependencies\EntityFramework.exe", but it didn't exist. (TaskId:16961)
For SearchPath "C:\Builds\10\OSS\Current\Sources\Current\_GAC Dependencies". (TaskId:16961)
Considered "C:\Builds\10\OSS\Current\Sources\Current\_GAC Dependencies\EntityFramework.dll", but it didn't exist. (TaskId:16961)
Considered "C:\Builds\10\OSS\Current\Sour