Skip to content

Instantly share code, notes, and snippets.

View seangwright's full-sized avatar
🐻
Still learning...

Sean G. Wright seangwright

🐻
Still learning...
View GitHub Profile
@seangwright
seangwright / Program.cs
Last active September 18, 2021 20:19
.NET 6 Console App w/ global usings
// See https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-usage
await Host
.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
services
.AddLogging()
.AddQuartz(quartz =>
{
quartz.SchedulerId = "Quartz-App";
quartz.SchedulerName = "Quartz-App";
@seangwright
seangwright / _Layout.cshtml
Created July 5, 2021 19:46
Kentico Xperience 13 Dancing Goat Core
@using Microsoft.AspNetCore.Mvc.Localization
@using Kentico.Activities.Web.Mvc
@using Kentico.Membership.Web.Mvc
@using Kentico.OnlineMarketing.Web.Mvc
@using DancingGoat.Helpers
@using DancingGoat.Widgets
@inject IHtmlLocalizer<SharedResources> HtmlLocalizer
@seangwright
seangwright / DefaultPageTemplateFilter.cs
Created March 14, 2021 23:54
Kentico Xperience Page Template Filter base class
/// <summary>
/// Default filter for associating Page Types to Page Templates
/// </summary>
public abstract class DefaultPageTemplateFilter : IPageTemplateFilter
{
/// <summary>
/// If true, then the templates returned by <see cref="FilterBy(PageTemplateDefinition)"/> are excluded from the results of <see cref="Filter(IEnumerable{PageTemplateDefinition}, PageTemplateFilterContext)"/>
/// when the <see cref="PageTypeClassName"/> does not match the Page Type of the context.
/// Defaults to false.
/// </summary>
@seangwright
seangwright / EmailMacroMethodContainer.cs
Created January 21, 2021 18:52
Reusable Xperience Email Transformations
using System;
using System.Collections.Generic;
using System.Linq;
using CMS;
using CMS.Helpers;
using CMS.MacroEngine;
using CMS.PortalEngine;
using CMS.SiteProvider;
using Sandbox.Infrastructure.Emails;
@seangwright
seangwright / web.config
Created January 19, 2021 05:45
Sample web.config from Kentico Xperience 13.0 Content Management application
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- Content staging BEGIN -->
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<!-- Content staging END -->
<!-- AjaxControlToolkit BEGIN -->
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false" />
<!-- AjaxControlToolkit END -->
</configSections>
@seangwright
seangwright / README.md
Created May 6, 2020 04:17
README sample for Kentico projects

project-code-name

Kentico 12 MVC application for <...>

Current Kentico

12.0.68

.NET Framework

@seangwright
seangwright / settings.json
Last active February 10, 2024 00:01
VS Code workspace settings for a Kentico 12 MVC + Vue.js CLI project
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"node_modules": true,
"obj": true,
"bin": true,
public static class PageTypeRouteAttributeCacheHelper
{
public static readonly Dictionary<string, ControllerActionPair> ClassNameLookup;
static PageTypeRouteAttributeCacheHelper()
{
var controllerTypes = typeof(PageTypeRouteAttributeCacheHelper)
.Assembly
.GetTypes()
.Where(t =>
@seangwright
seangwright / JsonDotNetValueProviderFactory.cs
Created June 26, 2019 06:12
Custom Json Serialization for ASP.NET MVC
/// <summary>
/// From https://github.com/garysharp/Disco/commit/1dfa3f4f15fe4fc093e90e4cd490dd06cc30cf07
/// </summary>
public class JsonDotNetValueProviderFactory : ValueProviderFactory
{
private readonly JsonSerializerSettings serializerSettings;
public JsonDotNetValueProviderFactory(JsonSerializerSettings serializerSettings)
{
Guard.Against.Null(serializerSettings, nameof(serializerSettings));
@seangwright
seangwright / ApiExceptionResult.cs
Last active June 26, 2019 05:58
Error Handling in Web Api 2
public class ApiExceptionResult : IHttpActionResult
{
private static readonly MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/json");
private readonly ApiError errorResponse;
private readonly JsonMediaTypeFormatter jsonMediaTypeFormatter;
private readonly HttpRequestMessage requestMessage;
private readonly HttpStatusCode statusCode;
public ApiExceptionResult(HttpRequestMessage requestMessage, HttpStatusCode statusCode, ApiError errorResponse, JsonMediaTypeFormatter jsonMediaTypeFormatter)