Skip to content

Instantly share code, notes, and snippets.

@bmcdavid
bmcdavid / CustomJsonSerializer.cs
Created Jul 2, 2018
Vulcan Episerver ContentRefernce Converter
View CustomJsonSerializer.cs
/// <summary>
/// Serializer for Vulcan content
/// </summary>
// ReSharper disable once InconsistentNaming
public class CustomJsonSerializer : JsonNetSerializer
private readonly IEnumerable<IVulcanIndexingModifier> _vulcanModifiers;
private static readonly Type IgnoreType = typeof(VulcanIgnoreAttribute);
View deletefiles.ts
import path = require('path');
import os = require('os');
import tl = require('vsts-task-lib/task');
tl.setResourcePath(path.join(__dirname, 'task.json'));
(() => {
let variableDelimiter: string = tl.getInput('VariableDelimiter', false);
variableDelimiter = variableDelimiter === null ? ";" : variableDelimiter;
// contents is a multiline input containing glob patterns
@bmcdavid
bmcdavid / CustomIndexModifier.cs
Created Apr 16, 2018
Example to search Episerver blocks in XhtmlString properties, requires Vulcan.Core > 3.x
View CustomIndexModifier.cs
using System.Collections.Generic;
using System.Linq;
using EPiServer.Core;
using EPiServer.Core.Html.StringParsing;
using EPiServer.Security;
using EPiServer.ServiceLocation;
using TcbInternetSolutions.Vulcan.Core;
using TcbInternetSolutions.Vulcan.Core.Extensions;
namespace WSOL.Web.Business.Vulcan
@bmcdavid
bmcdavid / RegistrationExtensions.cs
Created Mar 20, 2018
Demonstrates DotNetStarter using net core and DotNetStarter.RegistrationAbstractions only.
View RegistrationExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DotNetStarter.Abstractions;
using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyModel;
// todo: Set namespace
@bmcdavid
bmcdavid / DecorateTest.cs
Created Nov 22, 2017
Epi Test Decorator
View DecorateTest.cs
using System;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using System.Web.Mvc;
using System.Collections.Generic;
namespace AlloyCms11.Business.Initialization
{
public class DefaultProvider : DataAnnotationsModelMetadataProvider { }
@bmcdavid
bmcdavid / UnitTest1.cs
Created Nov 16, 2017
LightInject GetAll Sequence Order Test
View UnitTest1.cs
using LightInject;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace _LightInjectTests
{
public interface IFoo { }
public class FooOne : IFoo { }
@bmcdavid
bmcdavid / CustomProviderBasedLocalizationService.cs
Last active Feb 17, 2017
Custom Episerver Localization Service
View CustomProviderBasedLocalizationService.cs
using EPiServer.Framework;
using EPiServer.Framework.Localization;
using EPiServer.Framework.Localization.Internal;
using EPiServer.ServiceLocation;
using System;
using System.Globalization;
using System.Linq;
namespace WSOL.Web.Business
{
@bmcdavid
bmcdavid / AddScopedContainer.cs
Created Jan 19, 2017
Demo of adding scoped container dependency resolver.
View AddScopedContainer.cs
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using StructureMap;
using StructureMap.Pipeline;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace AlloyDemoKit.Business.Initialization
@bmcdavid
bmcdavid / WebApiRouting.cs
Created Dec 2, 2016
Example of Episerver Forms 3.0 and 4.0 Webhook handling.
View WebApiRouting.cs
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using System.Web.Http;
namespace AlloyTen.Business.Initialization
{
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class WebApiRouting : IInitializableModule
{
public void Initialize(InitializationEngine context)
@bmcdavid
bmcdavid / Global.asax.cs
Last active Aug 2, 2016
Handle errors in global.asax
View Global.asax.cs
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
HttpException httpException = exception as HttpException;
var configuration = WebConfigurationManager.OpenWebConfiguration("~/Web.config");
CustomErrorsSection customErrors = (CustomErrorsSection)configuration.GetSection("system.web/customErrors");
// if redirect mode
if (customErrors != null &&