Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 86887c5

Browse files
committed
Altered the semantics of some if statements
Changing the negation to an equals-false Plus some other C#7 syntax updates
1 parent cb9ba5c commit 86887c5

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplic
1515
{
1616
GlobalFilters.Filters.Add(new DocTypeGridEditorPreviewAttribute());
1717

18-
if (!DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent)
18+
if (DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent == false)
1919
{
2020
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
2121
}
@@ -64,4 +64,4 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
6464
};
6565
}
6666
}
67-
}
67+
}

src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static IPublishedContent ConvertValueToContent(string id, string contentT
4545

4646
private static IPublishedContent ConvertValue(string id, string contentTypeAlias, string dataJson)
4747
{
48-
using (var timer = ApplicationContext.Current.ProfilingLogger.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValue ({0}, {1})", id, contentTypeAlias)))
48+
using (ApplicationContext.Current.ProfilingLogger.DebugDuration<DocTypeGridEditorHelper>(string.Format("ConvertValue ({0}, {1})", id, contentTypeAlias)))
4949
{
5050
var contentTypes = GetContentTypesByAlias(contentTypeAlias);
5151
var properties = new List<IPublishedProperty>();
@@ -73,10 +73,10 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
7373

7474
var newValue = propEditor.ValueEditor.ConvertEditorToDb(contentPropData, jProp.Value);
7575

76-
/* Now that we have the DB stored value, we actually need to then convert it into it's
76+
/* Now that we have the DB stored value, we actually need to then convert it into its
7777
* XML serialized state as expected by the published property by calling ConvertDbToString
7878
*/
79-
var propType2 = contentTypes.ContentType.CompositionPropertyTypes.Single(x => x.Alias.InvariantEquals(propType.PropertyTypeAlias));
79+
var propType2 = contentTypes.ContentType.CompositionPropertyTypes.First(x => x.Alias.InvariantEquals(propType.PropertyTypeAlias));
8080

8181
Property prop2 = null;
8282
try
@@ -104,19 +104,18 @@ private static IPublishedContent ConvertValue(string id, string contentTypeAlias
104104
}
105105

106106
// Parse out the name manually
107-
object nameObj = null;
108-
if (propValues.TryGetValue("name", out nameObj))
107+
if (propValues.TryGetValue("name", out object nameObj))
109108
{
110109
// Do nothing, we just want to parse out the name if we can
111110
}
112111

113112
// Get the current request node we are embedded in
114-
var pcr = UmbracoContext.Current != null ? UmbracoContext.Current.PublishedContentRequest : null;
113+
var pcr = UmbracoContext.Current?.PublishedContentRequest;
115114
var containerNode = pcr != null && pcr.HasPublishedContent ? pcr.PublishedContent : null;
116115

117116
// Create the model based on our implementation of IPublishedContent
118117
IPublishedContent content = new DetachedPublishedContent(
119-
nameObj != null ? nameObj.ToString() : null,
118+
nameObj?.ToString(),
120119
contentTypes.PublishedContentType,
121120
properties.ToArray(),
122121
containerNode);
@@ -141,8 +140,7 @@ private static PreValueCollection GetPreValuesCollectionByDataTypeId(int dataTyp
141140

142141
private static ContentTypeContainer GetContentTypesByAlias(string contentTypeAlias)
143142
{
144-
Guid contentTypeGuid;
145-
if (Guid.TryParse(contentTypeAlias, out contentTypeGuid))
143+
if (Guid.TryParse(contentTypeAlias, out Guid contentTypeGuid))
146144
contentTypeAlias = GetContentTypeAliasByGuid(contentTypeGuid);
147145

148146
return (ContentTypeContainer)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(

src/Our.Umbraco.DocTypeGridEditor/Our.Umbraco.DocTypeGridEditor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</Reference>
4747
<Reference Include="cms, Version=1.0.5885.31228, Culture=neutral, processorArchitecture=MSIL">
4848
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\cms.dll</HintPath>
49-
<Private>True</Private>
49+
<Private>False</Private>
5050
</Reference>
5151
<Reference Include="interfaces, Version=1.0.5885.31225, Culture=neutral, processorArchitecture=MSIL">
5252
<HintPath>..\packages\UmbracoCms.Core.7.4.0\lib\interfaces.dll</HintPath>

src/Our.Umbraco.DocTypeGridEditor/Web/Extensions/HtmlHelperExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public static HtmlString RenderDocTypeGridEditorItem(
2424

2525
var controllerName = string.Concat(content.DocumentTypeAlias, "Surface");
2626

27-
if (!string.IsNullOrWhiteSpace(viewPath))
27+
if (string.IsNullOrWhiteSpace(viewPath) == false)
2828
viewPath = viewPath.EnsureEndsWith('/');
2929

30-
if (!string.IsNullOrWhiteSpace(previewViewPath))
30+
if (string.IsNullOrWhiteSpace(previewViewPath) == false)
3131
previewViewPath = previewViewPath.EnsureEndsWith('/');
3232

3333
// Try looking for surface controller with action named after the editor alias
34-
if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true))
34+
if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(controllerName, editorAlias, true))
3535
{
3636
return helper.Action(editorAlias, controllerName, new
3737
{
@@ -59,7 +59,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
5959
var defaultControllerName = defaultController.Name.Substring(0, defaultController.Name.LastIndexOf("Controller"));
6060

6161
// Try looking for an action named after the editor alias
62-
if (!editorAlias.IsNullOrWhiteSpace() && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true))
62+
if (string.IsNullOrWhiteSpace(editorAlias) == false && SurfaceControllerHelper.SurfaceControllerExists(defaultControllerName, editorAlias, true))
6363
{
6464
return helper.Action(editorAlias, defaultControllerName, new
6565
{
@@ -90,7 +90,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
9090
}
9191

9292
// Check for preview view
93-
if (!string.IsNullOrWhiteSpace(previewViewPath)
93+
if (string.IsNullOrWhiteSpace(previewViewPath) == false
9494
&& helper.ViewContext.RequestContext.HttpContext.Request.QueryString["dtgePreview"] == "1")
9595
{
9696
var fullPreviewViewPath = string.Concat(previewViewPath, editorAlias, ".cshtml");
@@ -113,7 +113,7 @@ public static HtmlString RenderDocTypeGridEditorItem(
113113
}
114114

115115
// Check for view path view
116-
if (!string.IsNullOrWhiteSpace(viewPath))
116+
if (string.IsNullOrWhiteSpace(viewPath) == false)
117117
{
118118
var fullViewPath = string.Concat(viewPath, editorAlias, ".cshtml");
119119
if (ViewEngines.Engines.ViewExists(helper.ViewContext, fullViewPath, true))

src/Our.Umbraco.DocTypeGridEditor/Web/Mvc/DefaultDocTypeGridEditorSurfaceControllerResolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Our.Umbraco.DocTypeGridEditor.Web.Mvc
77
{
88
/// <summary>
99
/// A resolver used to resolve the default SurfaceController that is used to render any front-end
10-
/// Umbraco partial when using Nested Content.
10+
/// Umbraco partial when using DocTypeGridEditor content.
1111
/// </summary>
1212
public class DefaultDocTypeGridEditorSurfaceControllerResolver : SingleObjectResolverBase<DefaultDocTypeGridEditorSurfaceControllerResolver, Type>
1313
{
@@ -43,7 +43,7 @@ public Type GetDefaultControllerType()
4343
/// <param name="type"></param>
4444
private void ValidateType(Type type)
4545
{
46-
if (!type.IsOfGenericType(typeof(DocTypeGridEditorSurfaceController<>)))
46+
if (type.IsOfGenericType(typeof(DocTypeGridEditorSurfaceController<>)) == false)
4747
{
4848
throw new InvalidOperationException($"The Type specified ({type}) is not of type {typeof(DocTypeGridEditorSurfaceController<>)}");
4949
}

0 commit comments

Comments
 (0)