Skip to content

Instantly share code, notes, and snippets.

View JimBobSquarePants's full-sized avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@jamiehowarth0
jamiehowarth0 / ApplicationStartupHandler.cs
Last active August 29, 2015 14:01
How to use uMapper to return strong POCO types in Umbraco MVC mode
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Web.Mvc;
using UmbracoStrongTypeViews.Controllers;
namespace UmbracoStrongTypeViews.App_Start {
public class ApplicationStartupHandler : IApplicationEventHandler {
public void SendMessage(MailMessage message)
{
HostingEnvironment.QueueBackgroundWorkItem(async (_) => {
using(var smtpClient = new SmtpClient()){
//configure client if needed
await smtpClient.SendMailAsync(message);
}
});
}
.NET Framework 4.5 selected
File > New Project > Visual C# > Web > ASP.NET Web Application > Empty
In Package Manager Console, https://nuget.org/api/v2/ selected as source
Install-Package UmbracoCms
F5 to run and install Umbraco
After that succeeds, back to Package Manager Console
update-package ImageProcessor -Source D:\Dropbox\Windows\Downloads
update-package ImageProcessor.Web -Source D:\Dropbox\Windows\Downloads
- Obviously "Source" is the folder where the downloaded nupkg files are
@leekelleher
leekelleher / 1-README.md
Last active August 29, 2015 14:06
Ditto - Example of mapping an Archetype property to custom POCO model/type

Here is an example of using Ditto to map an Archetype property to custom POCO model/type.


Let's say that we have an Archetype to represent some SEO meta-data, and we'll call the DocType property "metaData".

We'd have 3 properties in the Archetype:

  • metaTitle
  • metaDescription
@jamiepollock
jamiepollock / ExtensionMethods.cs
Last active August 29, 2015 14:07
Umbraco GetPropertyValueRecursively with custom logic to determine if a recursive value is valid
using System;
using System.Linq.Expressions;
using Umbraco.Core.Models;
using Umbraco.Web;
namespace My.Website.ExtensionMethods {
public static class UmbracoExtensions {
public static TPropertyValue GetPropertyValueRecursively<TPropertyValue>(this IPublishedContent content, string alias, Expression<Func<TPropertyValue, bool>> recursiveValueIsValidExpression, TPropertyValue defaultValue = default(TPropertyValue)) {
if (content.HasProperty(alias)) {
var value = content.GetPropertyValue<TPropertyValue>(alias);
@kid-cavaquinho
kid-cavaquinho / DictionaryDisplayNameAttribute
Last active August 29, 2015 14:10
Helpers for Umbraco dictionary usage over MVC models
public class DictionaryDisplayNameAttribute : DisplayNameAttribute
{
private readonly string resourceName;
public DictionaryDisplayNameAttribute(string resourceName)
: base()
{
this.resourceName = resourceName;
}
@zpqrtbnk
zpqrtbnk / Test.cs
Last active August 29, 2015 14:14
Recurse Vs Stack Benchmark
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestRunner
{
using System;
using System.Xml;
using Microsoft.Web.XmlTransform;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using umbraco.interfaces;
namespace Our.Umbraco.Packaging
{
public class ConfigTransformations : IPackageAction
@IcodeNet
IcodeNet / Umbraco Razor Script Retrieve CheckBox List Selected Values
Created May 1, 2012 10:13
Umbraco Razor Script Retrieve CheckBox List Selected Values
var optionList = DynamicModel.TypeOfRoom; // TypeOfRoom is the check-box List
//Multiple Checkboxes selected
if (DynamicModel.TypeOfRoom.GetType() == typeof(Umbraco.Framework.Dynamics.BendyObject)){
var options = DynamicModel.TypeOfRoom.__KeyedChildren;
foreach(var kv in options){
RoomType is -- > @kv.Value
}
}
@anaisbetts
anaisbetts / .gitattributes
Created December 3, 2014 16:26
USE THIS GITATTRIBUTES FOR EVERY NEW PROJECT FOREVER AND EVER
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp