Skip to content

Instantly share code, notes, and snippets.

View alasvant's full-sized avatar

Antti Alasvuo alasvant

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web;
using EPiServer;
using EPiServer.Core;
using EPiServer.Forms;
using EPiServer.Forms.Core.Internal;
using EPiServer.Forms.Core.Models;
using EPiServer.ServiceLocation;
using System;
using System.Collections.Generic;
using EPiServer.Core;
using EPiServer.Forms;
using EPiServer.Forms.Core.Models;
namespace AlloyWithFind.Features.FormsCustomPlaceholder
{
/// <summary>
/// Extension methods for <see cref="Submission.Data"/>.
@alasvant
alasvant / AuditLogging.xml
Created July 6, 2020 16:51
Sample localization of custom Episerver activity and its action types.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<languages>
<language name="English" id="en">
<changelog>
<activitytypes>
<contentsecurity>
<description>Content security</description>
<!-- ContentSecurityActionType -->
<recursivereplace>Recursive replace</recursivereplace>
<recursivemodify>Recursive modify</recursivemodify>
@alasvant
alasvant / AuditLogInitializationModule.cs
Created July 6, 2020 16:42
Sample code related to Episerver custom activity registration and access rights change activity log logging.
using System;
using System.Collections.Generic;
using System.Linq;
using EPiServer.DataAbstraction;
using EPiServer.DataAbstraction.Activities;
using EPiServer.DataAbstraction.Activities.Internal;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Logging;
using EPiServer.Security;
@alasvant
alasvant / ContentSecurityActivity.cs
Created July 6, 2020 16:35
Sample code for custom Episerver activity.
using System.Collections.Generic;
using EPiServer.DataAbstraction.Activities;
namespace EpiAuditLogging.Web.Features.AuditLogging
{
public class ContentSecurityActivity : Activity
{
/// <summary>
/// Name of this activity (used for example to register this activity).
/// </summary>
@alasvant
alasvant / ContentSecurityActionType.cs
Created July 6, 2020 16:27
Custom ContentSecurityActionType used in sample code about custom Episerver activity.
namespace EpiAuditLogging.Web.Features.AuditLogging
{
/// <summary>
/// Content security action type (maps directly to <see cref="EPiServer.Security.SecuritySaveType"/>).
/// </summary>
public enum ContentSecurityActionType
{
// same as EPiServer.Security.SecuritySaveType
None = 0,
@alasvant
alasvant / ContentDeliveryApiInitialization.cs
Created March 22, 2020 13:02
Sample Episerver Content Delivery API configuration with new options introduced in Episerver update 296 (https://world.episerver.com/releases/episerver---update-296/)
using System;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace ContentDelivery.NewFeatures.Web.Business.Initialization
{
[InitializableModule]
[ModuleDependency(typeof(EPiServer.ContentApi.Cms.ContentApiCmsInitialization))]
public class ContentDeliveryApiInitialization : IConfigurableModule
@alasvant
alasvant / ApiHttpRoutesInitializationModule.cs
Created January 12, 2020 13:01
Sample Episerver initialization module to add convention based Web API routes in an Add-On
using System.Web.Http;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
namespace AlloyFindWithWebApi.Business.Initialization
{
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class ApiHttpRoutesInitializationModule : IInitializableModule
{
@alasvant
alasvant / FixWebApiInitializationModule.cs
Created January 12, 2020 12:57
Sample Episerver initialization module to fix Web API 2 attribute routing if other code has already called GlobalConfiguration.Configure without calling MapHttpAttributes().
using System.Web.Http;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
namespace AlloyFindWithWebApi.Business.Initialization
{
[InitializableModule]
[ModuleDependency(typeof(FrameworkAspNetInitialization))]
public class FixWebApiInitializationModule : IInitializableModule
{
@alasvant
alasvant / ExtendedTinyMceInitialization.cs
Created December 15, 2019 17:15
Sample to config Episerver TinyMCE editor to use numeric entity encoding (code snippet from alloy config).
using EpiWithSearch.Models.Blocks;
using EpiWithSearch.Models.Pages;
using EPiServer.Cms.TinyMce.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace EpiWithSearch.Business.Initialization
{
[ModuleDependency(typeof(TinyMceInitialization))]