Skip to content

Instantly share code, notes, and snippets.

using System.Web.Mvc;
namespace System.Web.UI
{
public static class PageCommon
{
public static UrlHelper GetUrlHelper(this Control c)
{
return new UrlHelper(c.Page.Request.RequestContext);
}
var XSLT = @"
<stylesheet version=""1.0""
xmlns=""http://www.w3.org/1999/XSL/Transform"">
<output omit-xml-declaration=""yes""
method=""xml""
cdata-section-elements=""script"" />
<template match=""/"">
<apply-templates select=""*"" />
</template>
<template match=""body|p|br|ol|ul|li|sup|sub|a|table|tr|td|th|hr|h2|h3|h4|h5|h6"">
using System;
using System.Linq;
using Tridion.ContentManager.ContentManagement.Fields;
using Tridion.ContentManager.Templating;
using Tridion.ContentManager.Templating.Assembly;
using comm = Tridion.ContentManager.CommunicationManagement;
namespace Tridion.Training.Assemblies
{
[TcmTemplateTitle("Component Array")]
@esteewhy
esteewhy / EnumerableExtensions.cs
Created April 5, 2013 15:06
Nifty basic things missing in .NET framework: 1. Get property without worrying about null checks: someObject.IfNotNull(o => o.Property) (Nice side-effect is that accessor code is only executed when needed. Also, it's smart enough not to return null where empty collection would fit) 2. Generate sequence out of anything, say, from a node's parents…
using System.Collections.Generic;
namespace System.Linq
{
public static class EnumerableExtension
{
public static IEnumerable<T> Generate<T>(this T seed)
{
return new T[] { seed };
}
@esteewhy
esteewhy / BuilderFactory.cs
Created April 5, 2013 15:03
DD4T model builders must die. But before that they must learn to play nicely with Unity DI. Here's how.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Unity;
namespace Alitalia.ConsumerWeb.Mapping.Tridion
{
public class BuilderFactory
{
@esteewhy
esteewhy / FieldsExtensions.cs
Last active December 15, 2015 20:40
Collection of DD4T extensions
using System;
using System.Collections.Generic;
using System.Linq;
namespace DD4T.ContentModel
{
/// <summary>
/// Shortcuts for accessing component fields.
/// </summary>
public static partial class FieldsExtensions