Skip to content

Instantly share code, notes, and snippets.

View robertjf's full-sized avatar

Robert Foster robertjf

View GitHub Profile
@robertjf
robertjf / ConfigurationExtensions.cs
Last active August 14, 2021 10:56
Enhanced configuration management with Azure Key Vault - sample code for the blog post found at https://youritteam.com.au/blog/enhanced-configuration-management-with-azure-key-vault
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Client;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Serilog;
using System;
using System.Reflection;
@robertjf
robertjf / profile.json
Created June 23, 2019 20:44
Windows Console Profile with Powershell 7 preview and Ubuntu
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{79285a8e-036c-446f-8a9c-78994e34bf85}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@robertjf
robertjf / ExamineIndexer.cs
Last active January 11, 2019 08:33
Extract and index properties from StackedContent or NestedContent and aggregate them to a single indexed field. Umbraco v7
using Examine;
using Examine.Providers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
@robertjf
robertjf / nWebSecHttpHeaderSecurityModuleWrapper.cs
Created September 10, 2018 13:38
If you're implementing a custom IHttpModule or including a third party Module like NWebSec, here's one way to connect up to any events exposed by your module
public class MyGlobalEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var nWebSecHttpHeaderSecurityModule = umbracoApplication.Modules["NWebSecHttpHeaderSecurityModule"] as HttpHeaderSecurityModule;
if (nWebSecHttpHeaderSecurityModule != null)
{
nWebSecHttpHeaderSecurityModule.CspViolationReported += NWebSecHttpHeaderSecurityModule_CspViolationReported;
}
@robertjf
robertjf / ContentModelExtensions.cs
Last active April 23, 2018 19:33
Umbraco ContentModelExtensions
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
namespace Project.Code.Models.Content
{
public static class ContentModelExtensions
{
/// <summary>
@robertjf
robertjf / DittoNuPickerTypeConverter.cs
Last active October 4, 2016 19:29
NuPicker TypeConverter for Ditto - this allows Ditto to convert from a nuPickers.Picker object to the target type
using nuPickers;
using Our.Umbraco.Ditto;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Web;
@robertjf
robertjf / NestedContentCreator.cs
Last active April 5, 2018 13:43
NestedContentCreator - generate a NestedContent Property Value based on a Property Type and a list of dictionary items.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;