Skip to content

Instantly share code, notes, and snippets.

View casper-rasmussen's full-sized avatar

Casper Aagaard Rasmussen casper-rasmussen

View GitHub Profile
[ContentType(
DisplayName = "Fixed Image",
GUID = "[YOUR GUID HERE]")]
public class FixedImageFileMediaType : ImagePlaceholderMediaType
{
[Ignore]
public override int Height { get { return 400; } set { throw new NotSupportedException(); } }
[Ignore]
public override int Width { get { return 400; } set { throw new NotSupportedException(); } }
[ContentType(
DisplayName = "Flexible Image",
GUID = "[YOUR GUID HERE]")]
public class FlexibleImageFileMediaType : ImagePlaceholderMediaType
{
[Display(Name = "Height")]
[Range(10, 1000)]
[Required]
public override int Height { get; set; }
public class IsEditingCommerceRole : VirtualRoleProviderBase
{
public const string Name = "IsEditingCommerceRole";
private readonly IContentRepository _contentRepository;
public IsEditingCommerceRole()
{
this._contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
}
[ContentType(GUID = "EEB1904D-AC67-47E6-A825-D4E6464DC64C",
DisplayName = "Checkout Page Type",
GroupName = "Checkout",
Description = "Checkout Page Type")]
[Access(Access = AccessLevel.Create, Roles = IsEditingCommerceRole.Name)]
public class CheckoutPageType : PageData
{
//Properties goes here
}
[AdministrationSettings(
CodeOnly = true)]
[ContentType(
GUID = "[GUID]",
AvailableInEditMode = true,
DisplayName = "Custom Type")]
public class CustomContentType : ContentBase, ILocalizable
{
//Other properties goes here
}
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class CustomContentProviderInitialization : IInitializableModule
{
private bool _isInitialized;
public void Initialize(InitializationEngine context)
{
if (!this._isInitialized)
{
var contentProvider = context.Locate.Advanced.GetInstance<CustomContentProvider>();
public class CustomContentType : ContentBase, ILocalizable
{
//Other properties goes here
public virtual CultureInfo Language { get; set; }
public IEnumerable<CultureInfo> ExistingLanguages { get; set; }
public CultureInfo MasterLanguage { get; set; }
class JobNotificationManager : IJobNotificationManager
{
public bool TryGet(ScheduledJob job, bool success, string message, out INotification notification)
{
notification = default(INotification);
if (success)
return false;
notification = new Notification()
public interface IJobNotificationManager
{
bool TryGet(ScheduledJob job, bool success, string message, out INotification notification);
}
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class CommerceDependencyResolverInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Container.Configure(ConfigureContainer);
}
private static void ConfigureContainer(ConfigurationExpression container)