Skip to content

Commit

Permalink
dotnet format check && application of check
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrch committed Jul 15, 2024
1 parent 9d815ec commit 59c5fe2
Show file tree
Hide file tree
Showing 1,301 changed files with 4,055 additions and 3,851 deletions.
13 changes: 8 additions & 5 deletions KVA/Migration.Toolkit.Source/Auxiliary/NodeXmlAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
namespace Migration.Toolkit.Source.Auxiliary;
namespace Migration.Toolkit.Source.Auxiliary;

using System;
using System.Xml.Linq;
using Migration.Toolkit.Common;
using Migration.Toolkit.Common.Enumerations;

internal class NodeXmlAdapter {
internal class NodeXmlAdapter
{
private readonly XElement _xClass;

public bool ParsingSuccessful { get; }

public NodeXmlAdapter(string xml) {
public NodeXmlAdapter(string xml)
{
var xDoc = XDocument.Parse(xml);
if (xDoc.Root?.FirstNode is XElement dClass)
{
Expand All @@ -24,7 +26,8 @@ public NodeXmlAdapter(string xml) {
}
}

public string? GetValue(string columnName) {
public string? GetValue(string columnName)
{
return _xClass.Element(columnName)?.Value;
}

Expand Down Expand Up @@ -72,4 +75,4 @@ public bool HasValueSet(string columnName)
public string? ClassName => _xClass.Element(NodeXmlColumns.CLASS_NAME)?.Value;

public string? DocumentPageTemplateConfiguration => _xClass.Element(NodeXmlColumns.DOCUMENT_PAGE_TEMPLATE_CONFIGURATION)?.Value;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Migration.Toolkit.Source.Behaviors;
namespace Migration.Toolkit.Source.Behaviors;

using System.Diagnostics;
using MediatR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Migration.Toolkit.Source.Contexts;
namespace Migration.Toolkit.Source.Contexts;

using System.Diagnostics;
using System.Linq.Expressions;
Expand Down
4 changes: 2 additions & 2 deletions KVA/Migration.Toolkit.Source/Exceptions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Migration.Toolkit.Source;

public class MappingFailureException: InvalidOperationException
public class MappingFailureException : InvalidOperationException
{
public string KeyName { get; }
public string Reason { get; }

public MappingFailureException(string keyName, string reason): base($"Key '{keyName}' mapping failed: {reason}")
public MappingFailureException(string keyName, string reason) : base($"Key '{keyName}' mapping failed: {reason}")
{
KeyName = keyName;
Reason = reason;
Expand Down
26 changes: 13 additions & 13 deletions KVA/Migration.Toolkit.Source/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ public static async Task<AssertSuccessResult<TResult>> AssertSuccess<TResult>(th
switch (await resultTask)
{
case { Success: true, Imported: TResult info }:
{
return new(true, info);
}
case {} result:
{
var sb = new StringBuilder();
if (result.ModelValidationResults is { } validationResults)
validationResults.ForEach(vr => sb.Append($"[{string.Join(",", vr.MemberNames)}]: {vr.ErrorMessage}"));

if (result.Exception is { } exception)
{
logger.LogError(exception, "Error occured while importing entity {ValidationErrors}", sb);
return new(true, info);
}
case { } result:
{
var sb = new StringBuilder();
if (result.ModelValidationResults is { } validationResults)
validationResults.ForEach(vr => sb.Append($"[{string.Join(",", vr.MemberNames)}]: {vr.ErrorMessage}"));

if (result.Exception is { } exception)
{
logger.LogError(exception, "Error occured while importing entity {ValidationErrors}", sb);
}
return new(false, default);
}
return new(false, default);
}
default: throw new NotImplementedException("Undefined state");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ FROM View_CMS_Tree_Joined [TJ]
{
if (await importer
.ImportAsync(umtModel)
.AssertSuccess<TagInfo>(logger) is {Success:true, Info: {} tag})
.AssertSuccess<TagInfo>(logger) is { Success: true, Info: { } tag })
{
query = """
SELECT TJ.DocumentGUID, TJ.NodeSiteID, TJ.NodeID, TJ.DocumentID, CDC.CategoryID, TJ.DocumentCheckedOutVersionHistoryID, TJ.NodeClassID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private async Task MigrateClasses(EntityConfiguration entityConfiguration, Cance

protocol.FetchedTarget(xbkDataClass);

if (SaveClassUsingKxoApi(cmsClass, xbkDataClass) is {} savedDataClass)
if (SaveClassUsingKxoApi(cmsClass, xbkDataClass) is { } savedDataClass)
{
Debug.Assert(savedDataClass.ClassID != 0, "xbkDataClass.ClassID != 0");
xbkDataClass = DataClassInfoProvider.ProviderObject.Get(savedDataClass.ClassID);
Expand Down Expand Up @@ -162,7 +162,7 @@ private async Task MigrateClasses(EntityConfiguration entityConfiguration, Cance
}
catch (Exception ex)
{
logger.LogError(ex,"Error while copying data to table");
logger.LogError(ex, "Error while copying data to table");
}
}

Expand Down Expand Up @@ -272,7 +272,7 @@ private async Task MigrateAlternativeForms(ICmsClass k12Class, DataClassInfo xbk

try
{
if (mapped is { Success : true })
if (mapped is { Success: true })
{
var (alternativeFormInfo, newInstance) = mapped;
ArgumentNullException.ThrowIfNull(alternativeFormInfo, nameof(alternativeFormInfo));
Expand Down Expand Up @@ -367,7 +367,7 @@ private async Task MigrateResources(CancellationToken cancellationToken)

try
{
if (mapped is { Success : true })
if (mapped is { Success: true })
{
var (resourceInfo, newInstance) = mapped;
ArgumentNullException.ThrowIfNull(resourceInfo, nameof(resourceInfo));
Expand Down Expand Up @@ -398,7 +398,7 @@ private async Task MigrateResources(CancellationToken cancellationToken)

try
{
if (mapped is { Success : true } result)
if (mapped is { Success: true } result)
{
var (dataClassInfo, newInstance) = result;
ArgumentNullException.ThrowIfNull(dataClassInfo, nameof(dataClassInfo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private async Task MigrateCustomTables()

try
{
if (mapped is { Success : true } result)
if (mapped is { Success: true } result)
{
var (dataClassInfo, newInstance) = result;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Migration.Toolkit.Source.Handlers;
namespace Migration.Toolkit.Source.Handlers;

using System.Collections.Immutable;
using System.Diagnostics;
Expand Down Expand Up @@ -64,7 +64,7 @@ public async Task<CommandResult> Handle(MigrateFormsCommand request, Cancellatio
var mapped = cmsFormMapper.Map(ksCmsForm, kxoCmsForm);
protocol.MappedTarget(mapped);

if (mapped is { Success : true } result)
if (mapped is { Success: true } result)
{
var (cmsForm, newInstance) = result;
ArgumentNullException.ThrowIfNull(cmsForm, nameof(cmsForm));
Expand Down Expand Up @@ -222,7 +222,7 @@ private bool MapAndSaveUsingKxoApi(ICmsClass ksClass, DataClassInfo kxoDataClass
var mapped = dataClassMapper.Map(ksClass, kxoDataClass);
protocol.MappedTarget(mapped);

if (mapped is { Success : true })
if (mapped is { Success: true })
{
var (dataClassInfo, newInstance) = mapped;
ArgumentNullException.ThrowIfNull(dataClassInfo, nameof(dataClassInfo));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Migration.Toolkit.Source.Handlers;
namespace Migration.Toolkit.Source.Handlers;

using CMS.Base;
using CMS.MediaLibrary;
Expand Down Expand Up @@ -67,10 +67,10 @@ public async Task<CommandResult> Handle(MigrateMediaLibrariesCommand request, Ca
continue;
}

var mapped = mediaLibraryInfoMapper.Map(new (ksMediaLibrary, ksSite), mediaLibraryInfo);
var mapped = mediaLibraryInfoMapper.Map(new(ksMediaLibrary, ksSite), mediaLibraryInfo);
protocol.MappedTarget(mapped);

if (mapped is { Success : true } result)
if (mapped is { Success: true } result)
{
var (mfi, newInstance) = result;
ArgumentNullException.ThrowIfNull(mfi, nameof(mfi));
Expand Down Expand Up @@ -174,7 +174,7 @@ private async Task RequireMigratedMediaFiles(List<(IMediaLibrary sourceLibrary,
var mapped = mediaFileInfoMapper.Map(source, kxoMediaFile);
protocol.MappedTarget(mapped);

if (mapped is { Success : true } result)
if (mapped is { Success: true } result)
{
var (mf, newInstance) = result;
ArgumentNullException.ThrowIfNull(mf, nameof(mf));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Migration.Toolkit.Source.Handlers;
namespace Migration.Toolkit.Source.Handlers;

using CMS.ContentEngine;
using CMS.DataEngine;
Expand Down Expand Up @@ -134,7 +134,7 @@ private async Task MigratePageTemplateConfigurations()

try
{
if (mapped is { Success : true })
if (mapped is { Success: true })
{
var (dataClassInfo, newInstance) = mapped;
ArgumentNullException.ThrowIfNull(dataClassInfo, nameof(dataClassInfo));
Expand Down
Loading

0 comments on commit 59c5fe2

Please sign in to comment.