Skip to content

Instantly share code, notes, and snippets.

View johnathan-sewell's full-sized avatar

Johnathan Sewell johnathan-sewell

  • BLAST
  • Copenhagen
View GitHub Profile
@johnathan-sewell
johnathan-sewell / Paragraph.hbm.xml
Created December 16, 2010 13:24
Basic NHibernate Mapping File
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="My.Application.Paragraph, My.Application" lazy="false">
<id name="Id" access="field" column="Id" >
<generator class="identity" />
</id>
<property name="Text" access="field" column="Text"/>
<property name="DateCreated" access="field" column="DateCreated"/>
</class>
</hibernate-mapping>
@johnathan-sewell
johnathan-sewell / NHibernate.xml
Created December 16, 2010 13:24
NHibernate Configuration
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string_name">MyApplication</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.connection_string">Server=(local);initial catalog=Database1;User Id=User1;Password=Password;</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="show_sql">true</property>
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
@johnathan-sewell
johnathan-sewell / TestModule.cs
Created December 15, 2010 07:30
HttpModule for EPiServer
public class TestModule: IHttpModule
{
public void Init(HttpApplication context)
{
DataFactory.Instance.LoadingPage += LoadingPage;
}
public void LoadingPage(object sender, PageEventArgs e)
{
}
@johnathan-sewell
johnathan-sewell / Simple System.Net.WebRequest.cs
Created December 13, 2010 14:37
HttpWebRequest - read page into string
public static string GetPageAsString(Uri address)
{
var result = "";
var request = WebRequest.Create(address) as HttpWebRequest;
using (var response = request.GetResponse() as HttpWebResponse)
{
var reader = new StreamReader(response.GetResponseStream());
result = reader.ReadToEnd();