Skip to content

Instantly share code, notes, and snippets.

View MattisOlsson's full-sized avatar

Mattias Olsson MattisOlsson

View GitHub Profile
public class GenericLinkPropertyModel<T> : PropertyModel<T, PropertyLinkData<T>>, IExpandableProperty<T> where T: LinkData, new()
{
private readonly IUrlResolver _urlResolver;
public GenericLinkPropertyModel(PropertyLinkData<T> propertyLinkData, IUrlResolver urlResolver) : base(propertyLinkData)
{
_urlResolver = urlResolver;
Value = GetValue(propertyLinkData?.Link);
ExpandedValue = Value;
}
@MattisOlsson
MattisOlsson / ContentSelectorDialogWithIcons.js
Last active October 24, 2024 19:50
ContentSelectorWithIcons
define([
'dojo/_base/declare',
'dojo/_base/lang',
'epi-cms/widget/ContentSelectorDialog',
'epi-cms/widget/ContentTree',
"epi-cms/component/_ContentNavigationTreeNode"
], function(
declare,
lang,
@MattisOlsson
MattisOlsson / CategoryContentDataImporter.cs
Created August 23, 2019 11:37
Sample EpiCategories IContentDataImporter
public class CategoryContentImporter : IContentImporter
{
private readonly IContentImporter _defaultContentImporter;
private readonly IContentRepository _contentRepository;
public CategoryContentImporter(IContentImporter defaultContentImporter, IContentRepository contentRepository)
{
_defaultContentImporter = defaultContentImporter;
_contentRepository = contentRepository;
}
define("site/widget/CustomContextualContentForestStoreModel", [
// dojo
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/promise/all",
"dojo/when",
// epi
"epi-cms/core/ContentReference",
"epi-cms/widget/ContextualContentForestStoreModel"
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Configure(c =>
{
c.CamelCaseSerialization = true;
c.RemoveXmlFormatter = true;
});
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
System.Reflection.Assembly.GetTypes() +115
System.Linq.<SelectManyIterator>d__17`2.MoveNext() +259
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +275
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +193
Foundation.Core.Infrastructure.Initialization.ContentTypeUiDescriptorInitializer.GetDescriptorClasses() +781
Foundation.Core.Infrastructure.Initialization.ContentTypeUiDescriptorInitializer.Initialize(InitializationEngine context) +96
EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key) +55
EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context) +131
@MattisOlsson
MattisOlsson / MyContentType.cs
Created September 9, 2017 19:17
PropertyEditRestriction
public class MyContentType
{
[PropertyEditRestriction(new[] { "CmsAdmins" })
public virtual string MyProperty { get; set; }
}
@MattisOlsson
MattisOlsson / FacetExtensions.cs
Created September 30, 2016 08:25
Categories facet
public static class FacetExtensions
{
public static ITypeSearch<T> ContentCategoriesFacet<T>(this ITypeSearch<T> request) where T : ICategorizable
{
return request.HistogramFacetFor(x => x.Category, 1);
}
public static ITypeSearch<T> CategoriesFacet<T>(this ITypeSearch<T> request, Expression<Func<T, object>> fieldExpression) where T : ICategorizable
{
return request.HistogramFacetFor(fieldExpression, 1);
[ServiceConfiguration(typeof(ContentAreaRenderer), Lifecycle = ServiceInstanceScope.Singleton)]
public class ContainerAndRowContentAreaRenderer : ContentAreaRenderer
{
// Number of columns in site grid
protected const int NumberOfGridColumns = 12;
// TagBuilder for the current container div.
protected TagBuilder CurrentContainer;
// TagBuilder for the current row div.
using System;
using System.Linq;
using EPiServer.ServiceLocation;
using Geta.EPi.Checkout.Core.Infrastructure.Exceptions;
using Mediachase.Commerce.Orders;
using Mediachase.Commerce.Website;
using Mediachase.Commerce.Website.Helpers;
namespace Geta.EPi.Checkout.Core.Services
{