Skip to content

Commit

Permalink
Merge pull request #4 from geekrocket/develop
Browse files Browse the repository at this point in the history
Minor namespace and code style cleanup
  • Loading branch information
heikof authored Dec 7, 2016
2 parents 2727b63 + 9f1f1e9 commit c6bfe62
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/DeloitteDigital.Atlas/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DD.Atlas
namespace DeloitteDigital.Atlas
{
public static class Constants
{
Expand Down
20 changes: 10 additions & 10 deletions src/DeloitteDigital.Atlas/Extensions/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace DeloitteDigital.Atlas.Extensions
{

/// <summary>
/// Provides extention methods on the Sitecore.Data.Items.Item type
/// Provides extension methods on the Sitecore.Data.Items.Item type
/// </summary>
public static class ItemExtensions
{
Expand All @@ -37,15 +37,15 @@ public static string GetFieldValue(this Item item, string fieldName, bool pageEd
fieldRenderer.FieldName = fieldName;
if (attributes != null)
{
fieldRenderer.Parameters = String.Join("&",
attributes.Keys.Select(k => String.Format("{0}={1}", k, attributes[k])));
fieldRenderer.Parameters = string.Join("&",
attributes.Keys.Select(k => string.Format("{0}={1}", k, attributes[k])));
}
return fieldRenderer.Render();
}
else
{
var field = item.Fields[fieldName];
return field != null ? field.Value : String.Empty;
return field != null ? field.Value : string.Empty;
}
}

Expand Down Expand Up @@ -74,16 +74,16 @@ public static Item[] GetListFieldValueItems(this Item item, string fieldName)

public static string GetItemUrl(this Item item, string siteName = "", string hostName = "")
{
if (String.IsNullOrEmpty(siteName))
if (string.IsNullOrEmpty(siteName))
{
return LinkManager.GetItemUrl(item);
}
else
{
var itemUrl = String.Empty;
var itemUrl = string.Empty;
var originalSiteName = Context.Site.Name;
Context.SetActiveSite(siteName);
itemUrl = String.Format("//{0}{1}", hostName, LinkManager.GetItemUrl(item));
itemUrl = string.Format("//{0}{1}", hostName, LinkManager.GetItemUrl(item));
Context.SetActiveSite(originalSiteName);
return itemUrl;
}
Expand All @@ -97,7 +97,7 @@ public static bool GetFieldValueAsBool(this Item item, string fieldName)

public static string GetFieldValueAsDateTime(this Item item, string fieldName, string format = "")
{
if (String.IsNullOrEmpty(format))
if (string.IsNullOrEmpty(format))
{
format = "dd MMM yyyy";
}
Expand All @@ -120,7 +120,7 @@ public static string GetImageFieldMediaUrl(this Item item, string fieldName, int
}
else
{
return String.Empty;
return string.Empty;
}
}

Expand All @@ -139,7 +139,7 @@ public static string GetLinkFieldItemFieldValue(this Item item, string linkField
}
}

return String.Empty;
return string.Empty;
}

public static Item GetLinkFieldItem(this Item item, string fieldName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public static bool GetBoolean(this NameValueCollection nvc, string key, bool def
{
bool value;
var stringValue = nvc[key];
if (Boolean.TryParse(stringValue, out value))
if (bool.TryParse(stringValue, out value))
return value;

if (String.IsNullOrEmpty(stringValue))
if (string.IsNullOrEmpty(stringValue))
return null;

stringValue = stringValue.ToLowerInvariant();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Sites;
using Constants = DD.Atlas.Constants;

namespace DeloitteDigital.Atlas.Extensions
{
Expand Down
18 changes: 9 additions & 9 deletions src/DeloitteDigital.Atlas/Extensions/UrlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static string BuildUrl(this Uri uri, NameValueCollection queryStringParam
return uri.GetPathWithoutQuery();
}

return String.Empty;
return string.Empty;
}

/// <summary>
Expand All @@ -97,28 +97,28 @@ public static string BuildUrl(this HttpRequest httpContext, NameValueCollection
/// <param name="delimiter">The String to delimit the key/value pairs</param>
/// <param name="omitEmpty"></param>
/// <returns>A key/value structured query string, delimited by the specified String</returns>
public static string ToQueryString(this NameValueCollection parameters, String delimiter, Boolean omitEmpty)
public static string ToQueryString(this NameValueCollection parameters, string delimiter, bool omitEmpty)
{
if (String.IsNullOrEmpty(delimiter))
if (string.IsNullOrEmpty(delimiter))
delimiter = "&";

const char equals = '=';
if (parameters != null && parameters.Count > 0)
{
var items = new List<String>();
var items = new List<string>();
for (int i = 0; i < parameters.Count; i++)
{
foreach (String value in parameters.GetValues(i))
foreach (string value in parameters.GetValues(i))
{
Boolean addValue = !(omitEmpty) || !String.IsNullOrEmpty(value);
bool addValue = !(omitEmpty) || !string.IsNullOrEmpty(value);
if (addValue)
items.Add(String.Concat(parameters.GetKey(i), equals, HttpUtility.UrlEncode(value)));
items.Add(string.Concat(parameters.GetKey(i), equals, HttpUtility.UrlEncode(value)));
}
}
return String.Join(delimiter, items.ToArray());
return string.Join(delimiter, items.ToArray());
}

return String.Empty;
return string.Empty;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace DeloitteDigital.Atlas.FieldRendering
/// </summary>
public class EmptyRenderingString : IFieldRenderingString
{
private string emptyStringValue = String.Empty;
private string emptyStringValue = string.Empty;

public EmptyRenderingString() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public string UrlOnly()
}
else
{
return String.Empty;
return string.Empty;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DeloitteDigital.Atlas/Mvc/AdvancedModelLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override object GetModelFromTypeName(string typeName, string model, bo
}

throw new InvalidOperationException(
String.Format("Could not locate type '{0}'. Model reference: '{1}'",
string.Format("Could not locate type '{0}'. Model reference: '{1}'",
(object)typeName, (object)model));
}

Expand All @@ -53,7 +53,7 @@ protected override object GetModelFromTypeName(string typeName, string model, bo
}

throw new InvalidOperationException(
String.Format("Could not create a model object of type '{0}'. Model reference: '{1}'",
string.Format("Could not create a model object of type '{0}'. Model reference: '{1}'",
(object)typeName, (object)model));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/DeloitteDigital.Atlas/Mvc/ControllerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ protected override IController GetControllerInstance(RequestContext reqContext,

// Controller not found
if (controllerType == null)
throw new HttpException(404, String.Format(
throw new HttpException(404, string.Format(
"The controller for path '{0}' could not be found or it does not implement IController.",
reqContext.HttpContext.Request.Path));

// Controller type does not implement IController interface
if (!typeof(IController).IsAssignableFrom(controllerType))
throw new ArgumentException(String.Format(
throw new ArgumentException(string.Format(
"Type requested is not a controller: {0}", controllerType.Name),
"controllerType");
try
Expand All @@ -40,7 +40,7 @@ protected override IController GetControllerInstance(RequestContext reqContext,
}
catch (Exception ex)
{
throw new InvalidOperationException(String.Format(
throw new InvalidOperationException(string.Format(
"Error resolving controller {0}", controllerType.Name), ex);
}

Expand Down
3 changes: 1 addition & 2 deletions src/DeloitteDigital.Atlas/Mvc/RenderingModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using DD.Atlas;
using DeloitteDigital.Atlas.Caching;
using DeloitteDigital.Atlas.FieldRendering;
using DeloitteDigital.Atlas.Logging;
Expand All @@ -24,7 +23,7 @@ public string RenderingId
{
get
{
return String.Format("{0}{1}",
return string.Format("{0}{1}",
this.Rendering.RenderingItem.Name.Replace(" ", "_"),
this.Rendering.UniqueId.ToString().Substring(0, 6));
}
Expand Down

0 comments on commit c6bfe62

Please sign in to comment.