Skip to content

Instantly share code, notes, and snippets.

@thinkfreshnick
thinkfreshnick / blog-t4-code-gen-2.t4
Created June 25, 2021 11:12
T4 Sitecore Example
<#@ template language="C#" debug="true" #>
<#@ import namespace="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models" #>
<#@ parameter name="Model" type="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models.SitecoreItem" #>
<#
if (Model is SitecoreTemplate)
{
var template = Model as SitecoreTemplate;
#>
namespace <#= Model.Namespace #>
Text Block
<#
// control block
for (int i = 0; i < length; i++)
{
WriteLine(i);
}
#>
@thinkfreshnick
thinkfreshnick / blog-t4-code-gen-1.cs
Created June 25, 2021 10:07
Sitecore wrapper example
public class HomeItem : CustomItem
{
public HomeItem(Item innerItem) : base(innerItem)
{
}
public int NewsItemLimit
{
get { return Convert.ToInt32(this["News Item Limit"]); }
}
@thinkfreshnick
thinkfreshnick / MySigningTokenProvider.cs
Created February 5, 2018 13:38
A custom implementation of ITokenProvider that doesn't return a 500 response after a SecurityTokenInvalidLifetimeException is thrown but instead returns the intended 403 response.
using Sitecore;
using Sitecore.Services.Core.Configuration;
using Sitecore.Services.Core.Diagnostics;
using Sitecore.Services.Core.Security;
using Sitecore.Services.Infrastructure.Sitecore.Configuration;
using Sitecore.Services.Infrastructure.Sitecore.Diagnostics;
using Sitecore.Services.Infrastructure.Sitecore.Security;
using Sitecore.Services.Infrastructure.Web.Http.Security;
using System;
using System.Collections.Generic;
@thinkfreshnick
thinkfreshnick / InstallSitecoreInstallFramework.ps1
Last active May 23, 2019 05:52
Install latest version of the Sitecore Install Framework and remove any previously installed versions
Import-Module SitecoreInstallFramework
$Module = Get-Module SitecoreInstallFramework
Remove-Module $Module.Name
Remove-Item $Module.ModuleBase -Recurse -Force
Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2
Set-PSRepository -Name SitecoreGallery -InstallationPolicy Trusted
Install-Module SitecoreInstallFramework
Get-Module -Name SitecoreInstallFramework -ListAvailable