Skip to content

Instantly share code, notes, and snippets.

Avatar

John Rappel jraps20

View GitHub Profile
View Processor Parse.cs
public static Processor Parse(ProcessorItem item)
{
Sitecore.Diagnostics.Assert.ArgumentNotNull((object) item, nameof (item));
if (item.Disabled || item.Type.Trim().Length == 0)
return (Processor) null;
return new Processor(item);
}
View Pipeline.Start.cs
WorkflowPipelineArgs workflowPipelineArgs = new WorkflowPipelineArgs(item, null, null);
Pipeline pipeline = Pipeline.Start(stateItem, workflowPipelineArgs);
if (pipeline != null)
{
WorkflowCounters.ActionsExecuted.IncrementBy(pipeline.Processors.Count);
}
@jraps20
jraps20 / DictionaryValidator.cs
Created Apr 24, 2018
TDS Validator to ensure all uses of Translate.Text("some text") have a corresponding item defined in /sitecore/system/dictionary.
View DictionaryValidator.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using HedgehogDevelopment.SitecoreProject.Tasks;
using HedgehogDevelopment.SitecoreProject.Tasks.ProjectAnalysis;
namespace TDS.Validators
View LanguageFallbackValidator.cs
[Validator("Language Fallback Invalid", Status.Error, Description = "Validates all fields support language fallback. Add new properties to ignore templates that start with a particular path.")]
public class LanguageFallbackValidator : UserConfigurableValidator
{
private static readonly Guid Template = new Guid("{AB86861A-6030-46C5-B394-E8F99E8B87DB}");
public override IEnumerable<Problem> Validate(Dictionary<Guid, SitecoreDeployInfo> projectItems, XDocument scprojDocument)
{
var list = new List<Problem>();
foreach (var projectItem in projectItems)
{
View IndexableRenderings.xml
<indexableRenderings>
<rendering name="RichText" id="{4F8942FF-C4E4-408A-B3D5-4657EE5050CA}" />
</indexableRenderings>
@jraps20
jraps20 / GetDatasourceDependencies.cs
Last active Jan 12, 2018
Full set of classes and config changes required to index modular content in Sitecore, i.e. content that is added to the page as a separate rendering with a datasource. Configured to only index certain renderings based on config, to disallow indexing of renderings that may be "Related Items" or other types of renderings that are shared and not pe…
View GetDatasourceDependencies.cs
using System.Linq;
using Sitecore;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Pipelines.GetDependencies;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
namespace Common.Sitecore.Search.GetDependencies
{
View QueueRemoteEvent.cs
var remoteEvent = new LogMessageRemoteEvent(Sitecore.Configuration.Settings.InstanceName, "logMessage:remote");
Sitecore.Eventing.EventManager.QueueEvent<LogMessageRemoteEvent>(remoteEvent);
View LogMessageLocal.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="logMessage:remote">
<handler type="MyNamespace.LogMessageRemote, MyDll" method="LogInstanceName" />
</event>
</events>
</sitecore>
</configuration>
View LogMessageRemote.cs
public class LogMessageRemote
{
public void LogInstanceName(object sender, EventArgs args)
{
var logMessageArgs = args as RemoteEventArgs<LogMessageRemoteEvent>;
if (logMessageArgs == null)
throw new InvalidOperationException("Unexpected event args: {0}".FormatWith((object) args.GetType().FullName));
Log.Info($"Triggered from {logMessageArgs.InstanceName}.", (object) this);
}
View LogMessageRemote.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor type="MyNamespace.LogMessageRemoteMap, MyDll" method="Initialize" />
</initialize>
</pipelines>
</sitecore>
</configuration>