Skip to content

Commit

Permalink
Enabled StyleCop and added StyleCop dependency as git module
Browse files Browse the repository at this point in the history
  • Loading branch information
DotTech committed Mar 10, 2014
1 parent 4d057c7 commit 2552412
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 188 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "References/StyleCop"]
path = References/StyleCop
url = https://github.com/ParTech/StyleCop-Dependency.git
branch = master
1 change: 1 addition & 0 deletions References/StyleCop
Submodule StyleCop added at 556f9c
19 changes: 9 additions & 10 deletions Source/ParTech.Modules.UrlRewriter/Commands/ClearCache.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using ParTech.Modules.UrlRewriter.Events;
using ParTech.Modules.UrlRewriter.Pipelines;
using Sitecore;
using Sitecore.Events;
using Sitecore.Shell.Applications.Dialogs.ProgressBoxes;
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;

namespace ParTech.Modules.UrlRewriter.Commands
namespace ParTech.Modules.UrlRewriter.Commands
{
using ParTech.Modules.UrlRewriter.Events;
using Sitecore;
using Sitecore.Eventing;
using Sitecore.Events;
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;

/// <summary>
/// Clear the URL Rewriter cache by adding a ClearCacheEvent to the EventQueue.
/// </summary>
Expand Down Expand Up @@ -39,7 +38,7 @@ public void Confirm(ClientPipelineArgs args)
Event.RaiseEvent("urlrewriter:clearcache", new ClearCacheEventArgs(new ClearCacheEvent()));

// Add a ClearCacheEvent to the EventQueue to clear the cache on all instances.
Sitecore.Eventing.EventManager.QueueEvent<ClearCacheEvent>(new ClearCacheEvent(), true, false);
EventManager.QueueEvent(new ClearCacheEvent(), true, false);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/ParTech.Modules.UrlRewriter/Events/ClearCacheEvent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.Serialization;

namespace ParTech.Modules.UrlRewriter.Events
namespace ParTech.Modules.UrlRewriter.Events
{
using System.Runtime.Serialization;

/// <summary>
/// Represents the ClearCache event in the EventQueue.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Source/ParTech.Modules.UrlRewriter/Events/ClearCacheEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using Sitecore.Events;

namespace ParTech.Modules.UrlRewriter.Events
namespace ParTech.Modules.UrlRewriter.Events
{
using System;
using Sitecore.Events;

/// <summary>
/// EventArgs for ClearCacheEvent
/// </summary>
public class ClearCacheEventArgs : EventArgs, IPassNativeEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="ClearCacheEventArgs" /> class.
/// Initializes a new instance of the <see cref="ClearCacheEventArgs"/> class.
/// </summary>
/// <param name="e">/param>
/// <param name="e">The event.</param>
public ClearCacheEventArgs(ClearCacheEvent e)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using ParTech.Modules.UrlRewriter.Pipelines;
using Sitecore.Events;

namespace ParTech.Modules.UrlRewriter.Events
namespace ParTech.Modules.UrlRewriter.Events
{
using System;
using ParTech.Modules.UrlRewriter.Pipelines;
using Sitecore.Events;

/// <summary>
/// Handles cache clearing for the URL Rewriter.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Source/ParTech.Modules.UrlRewriter/Hooks/ClearCacheHook.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using ParTech.Modules.UrlRewriter.Events;
using Sitecore.Eventing;
using Sitecore.Events.Hooks;

namespace ParTech.Modules.UrlRewriter.Hooks
namespace ParTech.Modules.UrlRewriter.Hooks
{
using System;
using ParTech.Modules.UrlRewriter.Events;
using Sitecore.Eventing;
using Sitecore.Events.Hooks;

/// <summary>
/// Hook that subscribes the ClearCacheEvent to the EventQueue.
/// </summary>
Expand Down
52 changes: 24 additions & 28 deletions Source/ParTech.Modules.UrlRewriter/ItemIds.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Data;

namespace ParTech.Modules.UrlRewriter
namespace ParTech.Modules.UrlRewriter
{
using Sitecore.Data;

/// <summary>
/// References to Sitecore item ID's that belong to the Url Rewriter module.
/// </summary>
public static class ItemIds
{
/// <summary>
/// References to Sitecore templates that belong to the Url Rewriter module.
/// </summary>
public static class Templates
{
/// <summary>
/// Gets the ID for the Hostname Rewrite Rule template.
/// </summary>
public static readonly ID HostNameRewriteRule = new ID("{C0884868-FE60-4AD3-91DD-A5DB6DC1FA16}");

/// <summary>
/// Gets the ID for the URL Rewrite Rule template.
/// </summary>
public static readonly ID UrlRewriteRule = new ID("{24DB2387-14C3-46E3-B9B0-362E0D787424}");

/// <summary>
/// Gets the ID for the Rewrite Rules Folder template.
/// </summary>
public static readonly ID RewriteRulesFolder = new ID("{CBF22343-A180-46E9-B20D-329C9382E10C}");
}

/// <summary>
/// References to Sitecore fields that belong to the Url Rewriter module.
/// </summary>
Expand All @@ -57,5 +32,26 @@ public static class Fields
/// </summary>
public static readonly ID TargetHostName = new ID("{BE421AF4-DA73-4F12-89B5-2FBEFF6B7633}");
}

/// <summary>
/// References to Sitecore templates that belong to the Url Rewriter module.
/// </summary>
public static class Templates
{
/// <summary>
/// Gets the ID for the Hostname Rewrite Rule template.
/// </summary>
public static readonly ID HostNameRewriteRule = new ID("{C0884868-FE60-4AD3-91DD-A5DB6DC1FA16}");

/// <summary>
/// Gets the ID for the URL Rewrite Rule template.
/// </summary>
public static readonly ID UrlRewriteRule = new ID("{24DB2387-14C3-46E3-B9B0-362E0D787424}");

/// <summary>
/// Gets the ID for the Rewrite Rules Folder template.
/// </summary>
public static readonly ID RewriteRulesFolder = new ID("{CBF22343-A180-46E9-B20D-329C9382E10C}");
}
}
}
12 changes: 4 additions & 8 deletions Source/ParTech.Modules.UrlRewriter/Logging.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Diagnostics;

namespace ParTech.Modules.UrlRewriter
namespace ParTech.Modules.UrlRewriter
{
using Sitecore.Diagnostics;

/// <summary>
/// Provides methods for writing messages to the Sitecore log.
/// </summary>
Expand Down Expand Up @@ -36,4 +32,4 @@ public static void LogInfo(string message, object owner)
Log.Info(string.Format(logMessageFormat, message), owner);
}
}
}
}
16 changes: 6 additions & 10 deletions Source/ParTech.Modules.UrlRewriter/Models/HostNameRewriteRule.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Sitecore.Data;
using Sitecore.Data.Items;

namespace ParTech.Modules.UrlRewriter.Models
namespace ParTech.Modules.UrlRewriter.Models
{
using System.Text.RegularExpressions;
using Sitecore.Data;
using Sitecore.Data.Items;

/// <summary>
/// Represents a domain rewriting rule.
/// </summary>
Expand Down Expand Up @@ -86,4 +82,4 @@ public bool Validate()
return true;
}
}
}
}
23 changes: 10 additions & 13 deletions Source/ParTech.Modules.UrlRewriter/Models/UrlRewriteRule.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Data;
using Sitecore.Data.Items;

namespace ParTech.Modules.UrlRewriter.Models
namespace ParTech.Modules.UrlRewriter.Models
{
using System;
using Sitecore.Data;
using Sitecore.Data.Items;

/// <summary>
/// Represents a URL rewriting rule.
/// </summary>
Expand All @@ -19,7 +16,7 @@ public class UrlRewriteRule
/// Expected format is a relative or absolute URL (including protocol and hostname) and optionally a querystring.
/// e.g. /myfolder/mypage.html or http://www.mydomain.com/myfolder/mypage.html
/// </remarks>
private string sourceUrl;
private readonly string sourceUrl;

/// <summary>
/// Sitecore field value for the target URL.
Expand All @@ -28,7 +25,7 @@ public class UrlRewriteRule
/// Expected format is a relative or absolute URL (including protocol and hostname) and optionally a querystring.
/// e.g. /myfolder/mypage.html or http://www.mydomain.com/myfolder/mypage.html
/// </remarks>
private string targetUrl;
private readonly string targetUrl;

/// <summary>
/// Initializes a new instance of the <see cref="UrlRewriteRule" /> class.
Expand Down Expand Up @@ -58,7 +55,7 @@ public Uri GetSourceUrl(Uri requestUrl)

if (!Uri.IsWellFormedUriString(absoluteSourceUrl, UriKind.Absolute))
{
Logging.LogError(string.Format("Source URL '{0}' defined in rewrite rule item '{1}' is not well formed.", absoluteSourceUrl, ItemId), this);
Logging.LogError(string.Format("Source URL '{0}' defined in rewrite rule item '{1}' is not well formed.", absoluteSourceUrl, this.ItemId), this);
return default(Uri);
}

Expand All @@ -76,13 +73,13 @@ public Uri GetTargetUrl(Uri requestUrl)

if (!Uri.IsWellFormedUriString(absoluteTargetUrl, UriKind.Absolute))
{
Logging.LogError(string.Format("Target URL '{0}' defined in rewrite rule item '{1}' is not well formed.", absoluteTargetUrl, ItemId), this);
Logging.LogError(string.Format("Target URL '{0}' defined in rewrite rule item '{1}' is not well formed.", absoluteTargetUrl, this.ItemId), this);
return default(Uri);
}

return new Uri(absoluteTargetUrl);
}

/// <summary>
/// Validate the values of this rule and write an error to the Sitecore log if it's invalid.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -63,6 +64,7 @@
<Compile Include="UrlRewriterException.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)..\References\StyleCop\MSBuild\StyleCop.Targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Sitecore.Pipelines.GetContentEditorWarnings;

namespace ParTech.Modules.UrlRewriter.Pipelines
namespace ParTech.Modules.UrlRewriter.Pipelines
{
using System.Linq;
using System.Web;
using Sitecore.Pipelines.GetContentEditorWarnings;

/// <summary>
/// Implements an instruction manual on rewrite rules by adding Content Editor warnings when editing rewrite rule items.
/// </summary>
public class ApplyHelpNotifications
{
private readonly string urlHelpHideStateCookieName = "url-rewrite-help-hide";
/// <summary>
/// The cookie name for the cookie that tracks the state of the hostname rewrite rule instructions.
/// </summary>
private readonly string hostNameHelpHideStateCookieName = "hostname-rewrite-help-hide";

/// <summary>
/// The cookie name for the cookie that tracks the state of the url rewrite rule instructions.
/// </summary>
private readonly string urlHelpHideStateCookieName = "url-rewrite-help-hide";

/// <summary>
/// Process the pipeline processor.
/// </summary>
Expand Down Expand Up @@ -164,4 +168,4 @@ private string GetHideLink(string cookieName)
[Hide instructions]</a>";
}
}
}
}
Loading

0 comments on commit 2552412

Please sign in to comment.