Skip to content

Instantly share code, notes, and snippets.

View bmcdavid's full-sized avatar

Brad McDavid bmcdavid

View GitHub Profile
@bmcdavid
bmcdavid / 0_reuse_code.js
Created August 7, 2014 12:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
using EPiServer;
using EPiServer.Core;
using EPiServer.Shell.Services.Rest;
using EPiServer.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using WSOL.EPiServerCms.Web.Interfaces;
@bmcdavid
bmcdavid / Global.asax.cs
Last active August 2, 2016 19:25
Handle errors in global.asax
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 &&
@bmcdavid
bmcdavid / WebApiRouting.cs
Created December 2, 2016 18:37
Example of Episerver Forms 3.0 and 4.0 Webhook handling.
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 / AddScopedContainer.cs
Created January 19, 2017 13:28
Demo of adding scoped container dependency resolver.
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 / CustomProviderBasedLocalizationService.cs
Last active February 17, 2017 15:40
Custom Episerver Localization Service
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 / UnitTest1.cs
Created November 16, 2017 14:27
LightInject GetAll Sequence Order Test
using LightInject;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace _LightInjectTests
{
public interface IFoo { }
public class FooOne : IFoo { }
@bmcdavid
bmcdavid / DecorateTest.cs
Created November 22, 2017 02:09
Epi Test Decorator
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 / RegistrationExtensions.cs
Created March 20, 2018 15:15
Demonstrates DotNetStarter using net core and DotNetStarter.RegistrationAbstractions only.
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 / CustomIndexModifier.cs
Created April 16, 2018 20:20
Example to search Episerver blocks in XhtmlString properties, requires Vulcan.Core > 3.x
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