Skip to content

Instantly share code, notes, and snippets.

View gist:403858
ObjectFactory.Initialize(i =>
{
i.IgnoreStructureMapConfig = true;
i.AddRegistry(new NHibernateRegistry());
i.Scan(s =>
{
s.Assembly("Hyrmn.Web");
s.WithDefaultConventions();
});
i.For<IEmailer>().Use<Emailer>()
View gist:491261
string xmlString = SerializeResultsToXmlString(response);
return Content(xmlString, "application/xml", Encoding.UTF8);
private string SerializeResultsToXmlString(ApiResponse response)
{
var memoryStream = new MemoryStream();
var xs = new XmlSerializer(typeof(ApiResponse));
var xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
View gist:866127
public class SuperSecretMvcApplication : TurbineApplication
{
public virtual IContainer CreateContainer()
{
return ObjectFactory.Container;
}
public override void Startup()
{
log4net.Config.XmlConfigurator.Configure();
View gist:881599
[HasMany(typeof(POSPhoto), Inverse = true, Access = PropertyAccess.FieldCamelcaseUnderscore, Cascade = ManyRelationCascadeEnum.All, Lazy = true, RelationType = RelationType.Set )]
public virtual IEnumerable<POSPhoto> Photos
{
get
{
return _photos.AsReadOnly();
}
}
public virtual void AddPhoto(POSPhoto photo)
@hyrmn
hyrmn / gist:891759
Created Mar 29, 2011
This doesn't work for some reason
View gist:891759
PM> install-package mvcturbine.structuremap
Install-Package : Unable to find package 'mvcturbine.structuremap'.
At line:1 char:16
+ install-package <<<< mvcturbine.structuremap
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.Cmdlets.InstallPackageCmdlet
PM> install-package mvcturbine -version 3.0
Install-Package : Unable to find package 'mvcturbine'.
At line:1 char:16
View global.asax
public class HyrmnBlogApplication : TurbineApplication
{
public override void Startup()
{
ServiceLocatorManager.SetLocatorProvider(() => new StructureMapServiceLocator(ObjectFactory.Container));
base.Startup();
}
protected override void ShutdownContext()
@hyrmn
hyrmn / Bootstrapper.cs
Created Apr 5, 2011
app_start calls this structuremap bootstrapper
View Bootstrapper.cs
public static class Bootstrapper
{
public static void Initialize()
{
StructureMapConfigurator.ConfigureObjectFactory();
ObjectFactory.GetInstance<CitySearchService>().Initialize();
ObjectFactory.GetInstance<StatisticsService>().Initialize();
}
}
@hyrmn
hyrmn / gist:908100
Created Apr 7, 2011
How we include jQuery
View gist:908100
<script src="//ajax.googleapis.com/ajax/libs/jquery/${jqueryVersion}/jquery.js" type="text/javascript"></script>
<script type="text/javascript"> !window.jQuery && document.write(unescape('%3Cscript src="' + document.getElementById("rsVirtualRoot").value + 'content/js/jquery/${jqueryVersion}/jquery.min.js" %3E%3C/script%3E'))</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/${jqueryUiVersion}/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript"> !window.jQuery.ui && document.write(unescape('%3Cscript src="' + document.getElementById("rsVirtualRoot").value + 'content/js/jqueryui/${jqueryUiVersion}/jquery-ui.min.js" %3E%3C/script%3E'))</script>
@hyrmn
hyrmn / Bootstrapper.cs
Created Apr 10, 2011
How I did registration pre-turbine
View Bootstrapper.cs
public static class Bootstrapper
{
public static void Initialize()
{
StructureMapConfigurator.ConfigureObjectFactory();
}
}
View gist:3166690
using System;
using System.Collections.Generic;
using Xunit;
using Shouldly;
namespace ConsoleApplication1
{
public enum Decision
{