Shorthand.Optimizely.AllowedParents 0.2.0

dotnet add package Shorthand.Optimizely.AllowedParents --version 0.2.0                
NuGet\Install-Package Shorthand.Optimizely.AllowedParents -Version 0.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shorthand.Optimizely.AllowedParents" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shorthand.Optimizely.AllowedParents --version 0.2.0                
#r "nuget: Shorthand.Optimizely.AllowedParents, 0.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Shorthand.Optimizely.AllowedParents as a Cake Addin
#addin nuget:?package=Shorthand.Optimizely.AllowedParents&version=0.2.0

// Install Shorthand.Optimizely.AllowedParents as a Cake Tool
#tool nuget:?package=Shorthand.Optimizely.AllowedParents&version=0.2.0                

Shorthand.Optimizely.AllowedParents

Attributes and services to stop blocks from being created anywhere. Built for Optimizely 12 but could possibly be adapted to earlier versions quite easily.

Installation

> dotnet add package Shorthand.Optimizely.AllowedParents

Usage

Add the service interceptor in your Startup.cs file like this.

public void ConfigureServices(IServiceCollection services) {
    services.AddAllowedParents();
}

Then annotate your blocks like this.

[ContentType(
    DisplayName = "Container block",
    Description = "Container that is the only place where SpecificBlock should be used.",
    GUID = "03d80863-d9d0-46b2-90a5-a90cc5bc6fd7")]
public class ContainerBlock : BlockData {
    [Display(
        Name = "Container",
        Description = "Container for specific blocks.",
        GroupName = SystemTabNames.Content,
        Order = 1)]
    [AllowedTypes(typeof(SpecificBlock))]
    public virtual ContentArea? Container { get; set; }
}

[SiteContentType(
    DisplayName = "Speific block",
    Description = "A specific block that only makes sense within a container block.",
    GUID = "
5f731183-dbf2-4c29-94c0-ed9ddb9de2c2")]
[AllowedParents(typeof(ContainerBlock))]
public class SellingPointBlock : BlockData {
    ...
}

Or if you have a block that should never be created except by code.

[ContentType(
    DisplayName = "Footer block",
    GUID = "183eccc7-1e21-4501-a0cf-ba38f6828908")]
[AllowNoParents]
public class FooterBlock : BlockData {
    ...
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 7,095 11/25/2022
0.1.0 449 11/20/2022