Skip to content

Instantly share code, notes, and snippets.

View ChromeLauncher.cs
internal static class ChromeLauncher
{
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
private static string ChromeAppFileName
{
get
{
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ??
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null));
@fredrikhaglund
fredrikhaglund / Setup.cs
Created Jun 20, 2014
Check if a user is an admin and if not try to elevate the application by restarting itself. When using the verb "runas" User Account Control will popup a dialog and ask for permission to include administrative rights or to login as an administrator.
View Setup.cs
public static string ProcessFilename
{
get { return Process.GetCurrentProcess().MainModule.FileName; }
}
private static bool HasAdministrativeRight()
{
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
return windowsIdentity != null
&& new WindowsPrincipal(windowsIdentity).IsInRole(WindowsBuiltInRole.Administrator);
@fredrikhaglund
fredrikhaglund / AccordionContentArea.cshtml
Created Apr 11, 2018
How to render an Episerver ContentArea as an Accordion (using Bootstrap 2.x)
View AccordionContentArea.cshtml
@using EPiServer.Core
@using EPiServer.Editor
@using EPiServer.Web.Mvc.Html
@model EPiServer.Core.ContentArea
@* Note! Put this file in /Shared/DisplayTemplates/ to make it available as a template *@
@{
var idAccordion = Guid.NewGuid().ToString("N");
var first = true;
@fredrikhaglund
fredrikhaglund / ConsoleHelper.cs
Last active Jan 4, 2017
Require a Console from a non command line application (C#)
View ConsoleHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Launcher
{
class ConsoleHelper
{
@fredrikhaglund
fredrikhaglund / Lab: Course Import Lab
Last active Apr 12, 2016
This lab shows how to add a system integration job in EPiServer that loads a list of data and create, update and delete pages programmatically.
View Lab: Course Import Lab
This lab shows how to add a system integration job in EPiServer that loads a list of data and create, update and delete pages programmatically.
@fredrikhaglund
fredrikhaglund / Lab: Slide Show
Last active Apr 11, 2016
Lab: Slide Show block for Episerver CMS (using Bootstrap v2.0 like Alloy demo templates)
View Lab: Slide Show
Intended for EPiServer Alloy MVC demo templates or lab instructions for Episerver Fundamentals Developer training.
View ExternalStuffController.cs
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework.DataAnnotations;
using EPiServer.Web;
using EPiServer.Web.Mvc;
using EPiServer.Web.Routing;
using EPiServerSite9.Business;
@fredrikhaglund
fredrikhaglund / StartPageValidator.cs
Created Apr 1, 2015
EPiServer: Example of using IValidate
View StartPageValidator.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.SpecializedProperties;
using EPiServer.Validation;
namespace EPiServerSite5.Models.Pages
@fredrikhaglund
fredrikhaglund / TestPage.cs
Created Dec 14, 2014
EPiServer Developer Fundamentals - Demo of different editors and UI Extensions
View TestPage.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using EPiServer;
using EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.SelectionFactories;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
@fredrikhaglund
fredrikhaglund / SetupSnippet.cs
Last active Aug 29, 2015
How to register a protocol handler in C#
View SetupSnippet.cs
internal static class ChromeLauncher
{
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe";
private static string ChromeAppFileName
{
get
{
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ??
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null));