Skip to content

Instantly share code, notes, and snippets.

View sitereactor's full-sized avatar

Morten Christensen sitereactor

View GitHub Profile
@sitereactor
sitereactor / ProjectAllocationProcessor.cs
Last active August 29, 2015 13:56
Code sample for "Continuously receive messages async from Azure Service Bus Queues" posted here http://codereview.stackexchange.com/questions/41462/continuously-receive-messages-async-from-azure-service-bus-queues
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Concorde.AzurePack.Domain.Websites.Preallocation.Settings;
using Concorde.Contracts.Processes;
using Concorde.Infrastructure.Messaging;
using Microsoft.ServiceBus.Messaging;
namespace Allocation
@sitereactor
sitereactor / Subpage.cs
Last active December 22, 2015 14:39
Proof of concept for a simple TypedModelBase class with some sample model implementations. The idea is to use the TypedModelBase class for strongly typed models, which also enables strongly typed queries in your Umbraco MVC views. The code for these strongly typed models can be generated by Umbraco or created by the user (possibly in a code firs…
using System.Collections.Generic;
using Umbraco.Core.Models;
namespace Umbraco
{
/// <summary>
/// Represents a Subpage which acts as the strongly typed model for a Doc Type
/// with alias "Subpage" and "Subpage" as the allowed child type.
///
/// Similar to the Textpage this model could also be generated, but it could also
@sitereactor
sitereactor / NodeDto.cs
Created June 9, 2013 08:23
Example of a POCO that is used internally in Umbraco and decorated with various attributes to enable the creation of a table, columns, keys, constraints and indexes using .CreateTable().
using System;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Core.Models.Rdbms
{
[TableName("umbracoNode")]
[PrimaryKey("id")]
[ExplicitColumns]
internal class NodeDto
@sitereactor
sitereactor / NewCmsContentType2ContentTypeTable.cs
Created June 9, 2013 08:16
Example of a database migration used in the Core of Umbraco to create a new table with two columns for the upgrade - as well as deleting the same table and columns as part of the downgrade.
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
{
[Migration("6.0.0", 4, GlobalSettings.UmbracoMigrationName)]
public class NewCmsContentType2ContentTypeTable : MigrationBase
{
public override void Up()
{
Create.Table("cmsContentType2ContentType")
@sitereactor
sitereactor / RemoveNodeFromContentTree.cs
Created June 5, 2013 13:39
Very basic example of removing a node from the Content tree by a DocumentType alias.
using System;
using umbraco.BusinessLogic;
using umbraco.cms.presentation.Trees;
public class SecrectContent : ApplicationBase
{
public SecrectContent()
{
BaseContentTree.AfterNodeRender += BaseContentTree_AfterNodeRender;
}
using System;
using Umbraco.Core;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Examples
{
/// <summary>
/// Class that shows the use of creating a new table and inserting a new ArticlePoco.
/// This class is only intended for demo'ing and should not be used as it.
internal class ServiceContextManager : IDisposable
{
private readonly string _connectionString;
private readonly string _providerName;
private ServiceContext _serviceContext;
private readonly StandaloneApplication _application;
public ServiceContextManager(string connectionString, string providerName)
{
_connectionString = connectionString;
@sitereactor
sitereactor / UpdateRenderingEngineToMvc
Created April 8, 2013 14:51
Updates the DefaultRenderingEngine in the umbracoSettings.config file
public class UpdateRenderingEngineToMvc()
{
//Local variables
var path = GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar;
var filePath = path + "umbracoSettings.config";
var value = RenderingEngine.Mvc;
//Load the config file as xml
var xml = new XmlDocument();
var settingsReader = new XmlTextReader(filePath);
@sitereactor
sitereactor / WebApiUmbracoController.cs
Created February 7, 2013 15:34
Basic example of a WebApi Controller getting a ContentService in the constructor.
using System;
using System;
using System.Net.Http;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace Example.Controllers
{
public class WebApiUmbracoController : ApiController
@sitereactor
sitereactor / GoogleAnalyticsCacher.ashx.cs
Created May 4, 2012 18:42
Google Analytics data cacher used with Umbraco to cache stats to local json file
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using Google.GData.Analytics;
using Google.GData.Client;
using ServiceStack.Text;