Skip to content

Instantly share code, notes, and snippets.

View AndyButland's full-sized avatar

Andy Butland AndyButland

View GitHub Profile
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Routing;
namespace Umbraco.Cms.Web.UI.Composers;
public class SoftwarePageUrlsComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.UrlProviders().Insert<SoftwarePageUrlProvider>();
namespace MyProject.Web.Customization;
public static class SoftwarePageUrlHelper
{
public static bool IsSoftwarePage(string contentTypeAlias, string? contentName) =>
contentTypeAlias == "testPage" &&
!string.IsNullOrEmpty(contentName) &&
contentName.EndsWith(" Software");
}
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Strings;
namespace MyProject.Web.Customization;
public class SoftwarePageUrlSegmentProvider : IUrlSegmentProvider
{
private readonly IUrlSegmentProvider _provider;
public SoftwarePageUrlSegmentProvider(IShortStringHelper stringHelper) => _provider = new DefaultUrlSegmentProvider(stringHelper);
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
namespace MyProject.Web.Customization;
public class SoftwarePageContentFinder : IContentFinder
{
private readonly IDocumentUrlService _documentUrlService;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.Navigation;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Core.Web;
var commands = new List<ImageUrlGenerationOptions>();
imageUrlGeneratorMock.Verify(x => x.GetImageUrl(Capture.In(commands, cmd => true)));
foreach (ImageUrlGenerationOptions command in commands)
{
System.Diagnostics.Debug.WriteLine(command.Height);
}
imageUrlGeneratorMock
.Setup(x => x.GetImageUrl(It.IsAny<ImageUrlGenerationOptions>()))
.Returns("/test.png");
imageUrlGeneratorMock
.Setup(x => x.GetImageUrl(It.Is<ImageUrlGenerationOptions>(y => y.Height == Height)))
.Returns("/test.png");
public async Task Get(string id)
{
var response = await_authorizedServiceCaller.GetRequestAsyncContactResponse>(
"hubspot",
$"/crm/v3/objects/contacts/{id}");
if (response == null)
{
return NotFound();
}
[ApiExplorerSettings(GroupName = "forms")]