Skip to content

Instantly share code, notes, and snippets.

View micklaw's full-sized avatar
🏴󠁧󠁢󠁳󠁣󠁴󠁿
In contract until Aug 25

Michael Law micklaw

🏴󠁧󠁢󠁳󠁣󠁴󠁿
In contract until Aug 25
View GitHub Profile
@micklaw
micklaw / gist:a9e41b513fd7dfd69ea8
Created May 8, 2015 15:37
Inject Examine Fields
public void InjectToExamineNode(int id, Dictionary<string, string> newFields = null)
{
if (newFields.HasContent())
{
var content = new Content(id);
if (content.Id > 0)
{
var doc = content.ToXDocument(false).Root;
[UmbracoRoute("Home", Action = "Index")] // [ML] - index not required really, just added for demo purposes
public class Homepage : Page
{
public Homepage(IPublishedContent content) : base(content) { }
public string Title { get; set; }
}
@micklaw
micklaw / gist:0e3b4167651b1bb4ee07
Created May 3, 2015 14:59
Umbraco routing IHttpHandler
public class YomegoCMSHandler : IHttpHandler
{
public bool IsReusable { get; private set; }
private RequestContext _requestContext { get; set; }
public YomegoCMSHandler(RequestContext requestContext)
{
_requestContext = requestContext;
public class YomegoCMSRouteConstraint : IRouteConstraint
{
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
return IsRoutable(httpContext);
}
private bool PopulateContext(CoreApp<CoreServiceContainer> app, HttpContextBase context, string url, UmbracoRouteAttribute contentType = null)
{
// [ML ] -If this request has previously been routed, do nothing and route as context is populated
@micklaw
micklaw / gist:fb6dbdd50510a659025e
Created May 3, 2015 14:41
Umbraco route startup
public static void RegisterRoutes(RouteCollection routes)
{
var umbraco = new Route("{*url}", new RouteValueDictionary() { }, new RouteValueDictionary() { { "url", new YomegoCMSRouteConstraint() } }, new YomegoCMSRouteHandler());
routes.Add(umbraco);
}
public static void Method<T>(string something) {
}