Skip to content

Instantly share code, notes, and snippets.

ObjectFactory.Initialize(i =>
{
i.IgnoreStructureMapConfig = true;
i.AddRegistry(new NHibernateRegistry());
i.Scan(s =>
{
s.Assembly("Hyrmn.Web");
s.WithDefaultConventions();
});
i.For<IEmailer>().Use<Emailer>()
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);
public class SuperSecretMvcApplication : TurbineApplication
{
public virtual IContainer CreateContainer()
{
return ObjectFactory.Container;
}
public override void Startup()
{
log4net.Config.XmlConfigurator.Configure();
[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 March 29, 2011 03:28
This doesn't work for some reason
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
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 April 5, 2011 16:15
app_start calls this structuremap bootstrapper
public static class Bootstrapper
{
public static void Initialize()
{
StructureMapConfigurator.ConfigureObjectFactory();
ObjectFactory.GetInstance<CitySearchService>().Initialize();
ObjectFactory.GetInstance<StatisticsService>().Initialize();
}
}
@hyrmn
hyrmn / gist:908100
Created April 7, 2011 16:10
How we include jQuery
<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 April 10, 2011 12:42
How I did registration pre-turbine
public static class Bootstrapper
{
public static void Initialize()
{
StructureMapConfigurator.ConfigureObjectFactory();
}
}
using System;
using System.Collections.Generic;
using Xunit;
using Shouldly;
namespace ConsoleApplication1
{
public enum Decision
{