Skip to content

Instantly share code, notes, and snippets.

@mikeedwards83
mikeedwards83 / StronglyTypedExample.cs
Created August 23, 2011 05:30
Example of potential strongly typed Sitecore Query using Glass.Sitecore.Mapper
[SitecoreClass]
public class DummyClass{
[SitecoreField]
public virtual string MyField{get;set;}
[SitecoreField]
public virtual DateTime Date{get;set;}
}
import org.omg.CosNaming.NamingContextPackage.NotFound
// these are the data types
trait Tense{
}
case object Past extends Tense
case object Present extends Tense
case object Future extends Tense
@mikeedwards83
mikeedwards83 / Glass.Sitecore.Mapper.cs
Created January 18, 2012 20:33
Example of Multiple Loader Setup
_context = new Context(
config,
new MyModuleConfig(),
new MyModuleConfig2());
//this class is in another assembly
public class MyModuleConfig : IModuleConfiguration{
@mikeedwards83
mikeedwards83 / ToManyService.cs
Created January 18, 2012 20:50
An example of too many service
public class MyClass{
public MyClass(
ISitecoreServiceFactory factory)
{
}
}
@mikeedwards83
mikeedwards83 / ConstructorInjection.cs
Created January 18, 2012 21:52
Bad code for constructor injection
//from SitecoreClassConfig
internal delegate object Instantiator0();
internal delegate object Instantiator1(object arg1);
internal delegate object Instantiator2(object arg1, object arg2);
internal Dictionary<string, Delegate> CreateObjectMethods { get; set; }
//From SitecoreService.cs
ISitecoreContext context = new SitecoreContext();
this.Model = context.GetHomeItem<HomePage>();
@mikeedwards83
mikeedwards83 / GlassUserControl.cs
Created April 1, 2012 17:58
GlassUserControl demo of a page editor user control
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Glass.Sitecore.Mapper;
using System.Linq.Expressions;
namespace Glass.Demo.Application.Web.Controls
{
@mikeedwards83
mikeedwards83 / GlassUserControlExample.cs
Created April 1, 2012 18:00
Example layout using GlassUserControl
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Glass.Demo.Application.Models.EdDemo;
using Glass.Demo.Application.Web.Controls;
namespace Glass.Demo.Website.layouts
@mikeedwards83
mikeedwards83 / GlassUserControlExample.aspx
Created April 1, 2012 18:01
GlassUserControl example ASPX page
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestSublayout.ascx.cs" Inherits="Glass.Demo.Website.layouts.TestSublayout" %>
<%= Field(x => x.Title) %>
@mikeedwards83
mikeedwards83 / DynamicUserControl.aspx
Created April 4, 2012 20:12
Example of Dynamic UserControl
<%@ Control Language="C#" AutoEventWireup="true" Inherits="Glass.Demo.Application.Web.Controls.GlassDynamicUserControl, Glass.Demo.Application" %>
<h1>Dynamic Demo</h1>
<%=this.Model.Title %>
<%foreach(var child in this.Model.Children){ %>
<%= child.Name %>
<%} %>