This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> .\build-iar.ps1 -UnicornItemsRootPath c:\Temp\unicorn-cleanup\Unicorn\ -UnicornConfigsRootPath c:\Temp\unicorn-cleanup\App_Config\Include\ -OutputPath c:\Temp\unicorn-cleanup\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[ValidateScript({ Test-Path $_ -PathType Container })] | |
[string]$UnicornConfigsRootPath, | |
[ValidateScript({ Test-Path $_ -PathType Container })] | |
[string]$UnicornItemsRootPath, | |
[string]$OutputPath | |
) | |
Install-Module powershell-yaml -Scope CurrentUser -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
... | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
// Overwrite the default ApiContentResponseBuilder to resolve partial layouts | |
services.AddSingleton<IApiContentResponseBuilder, ExtendedApiContentResponseBuilder>(); | |
services.AddSingleton<IComponentResolver, HeaderResolver>(); | |
services.AddSingleton<IComponentResolver, FooterResolver>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExtendedApiContentResponseBuilder : LayoutBuilderBase<IApiContentResponse>, IApiContentResponseBuilder | |
{ | |
private readonly IApiContentRouteBuilder _apiContentRouteBuilder; | |
public ExtendedApiContentResponseBuilder( | |
IApiContentNameProvider apiContentNameProvider, | |
IApiContentRouteBuilder apiContentRouteBuilder, | |
IOutputExpansionStrategyAccessor outputExpansionStrategyAccessor, | |
IEnumerable<IComponentResolver> componentResolvers, | |
IApiPublishedContentCache apiPublishedContentCache) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class LayoutBuilderBase<T> : ApiContentBuilderBase<T> where T : IApiContent | |
{ | |
private const string LayoutPropertyKey = "layout"; | |
protected readonly IEnumerable<IComponentResolver> ComponentResolvers; | |
protected readonly IApiPublishedContentCache ApiPublishedContentCache; | |
protected LayoutBuilderBase( | |
IApiContentNameProvider apiContentNameProvider, | |
IApiContentRouteBuilder apiContentRouteBuilder, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IComponentResolver | |
{ | |
int Order { get; } | |
IPublishedContent ResolveContent(IPublishedContent content); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HeaderResolver : IComponentResolver | |
{ | |
public int Order => -100; | |
private readonly IApiPublishedContentCache _apiPublishedContentCache; | |
public HeaderResolver(IApiPublishedContentCache apiPublishedContentCache) | |
{ | |
_apiPublishedContentCache = apiPublishedContentCache; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FallbackDeliveryApiJsonTypeResolver : DeliveryApiJsonTypeResolver | |
{ | |
public override JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions options) | |
{ | |
var typeInfo = base.GetTypeInfo(type, options); | |
if (typeInfo.PolymorphismOptions != null) | |
{ | |
typeInfo.PolymorphismOptions.UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExtendedApiContentResponse : ApiContentResponse, IApiContentResponse | |
{ | |
public ExtendedApiContentResponse( | |
Guid id, | |
string name, | |
string contentType, | |
DateTime createDate, | |
DateTime updateDate, | |
IApiContentRoute route, | |
IDictionary<string, object?> properties, |
NewerOlder