Skip to content

Commit

Permalink
Formatting code for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuck committed May 12, 2021
1 parent 97b1c35 commit ea792ca
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 67 deletions.
9 changes: 5 additions & 4 deletions src/YuckQi.Domain.Services/Models/TypeSearchCriteria.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using YuckQi.Domain.ValueObjects.Abstract;
using System;
using YuckQi.Domain.ValueObjects.Abstract;

namespace YuckQi.Domain.Services.Models
{
public class TypeSearchCriteria : IPage
{
public string Name { get; set; }
public int PageNumber { get; set; }
public int PageSize { get; set; }
public String Name { get; set; }
public Int32 PageNumber { get; set; }
public Int32 PageSize { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/YuckQi.Domain.Services/YuckQi.Domain.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.4.9</Version>
<Version>0.5.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>A .NET library for bootstrapping a domain services project.</Description>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class DomainValidationException : ApplicationException
{
#region Constants

private const string DefaultErrorMessage = "Something went wrong.";
private const String DefaultErrorMessage = "Something went wrong.";

#endregion

Expand All @@ -31,7 +31,7 @@ public DomainValidationException(Result result) : base(GetErrorMessage(result))

#region Supporting Methods

private static string GetErrorMessage(Result result)
private static String GetErrorMessage(Result result)
{
if (result == null)
return DefaultErrorMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;

namespace YuckQi.Domain.Validation.Extensions
{
public static class AbstractValidatorExtensions
{
private const string AbstractValidatorFailedMessageId = "YQDV.01";
private const String AbstractValidatorFailedMessageId = "YQDV.01";

public static Result<T> GetResult<T>(this AbstractValidator<T> validator, T item)
{
Expand All @@ -17,7 +19,14 @@ public static Result<T> GetResult<T>(this AbstractValidator<T> validator, T item
if (result.IsValid)
return new Result<T>(item);

return new Result<T>(default, result.Errors.Select(t => new ResultDetail(ResultCode.InvalidRequestDetail, new ResultMessage(AbstractValidatorFailedMessageId, t.ErrorMessage), t.PropertyName)).ToList());
return new Result<T>(default, GetResultDetail(result));
}

private static IReadOnlyCollection<ResultDetail> GetResultDetail(ValidationResult result)
{
return result?.Errors
.Select(t => new ResultDetail(ResultCode.InvalidRequestDetail, new ResultMessage(AbstractValidatorFailedMessageId, t.ErrorMessage), t.PropertyName))
.ToList();
}
}
}
9 changes: 4 additions & 5 deletions src/YuckQi.Domain.Validation/Result.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

namespace YuckQi.Domain.Validation
Expand All @@ -9,7 +10,7 @@ public class Result

public IReadOnlyCollection<ResultDetail> Detail { get; }

public bool IsValid => Detail == null || Detail.All(t => t.Type != ResultType.Error);
public Boolean IsValid => Detail == null || Detail.All(t => t.Type != ResultType.Error);

#endregion

Expand All @@ -35,9 +36,7 @@ public class Result<T> : Result

#region Constructors

public Result(ResultDetail detail) : base(new List<ResultDetail> { detail })
{
}
public Result(ResultDetail detail) : base(new List<ResultDetail> {detail}) { }

public Result(T payload, IReadOnlyCollection<ResultDetail> detail = null) : base(detail)
{
Expand Down
28 changes: 9 additions & 19 deletions src/YuckQi.Domain.Validation/ResultCode.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
namespace YuckQi.Domain.Validation
using System;

namespace YuckQi.Domain.Validation
{
public readonly struct ResultCode
{
#region Private Members

private readonly string _code;
private readonly String _code;

#endregion


#region Implicit Operators

public static implicit operator string(ResultCode resultCode)
{
return resultCode._code;
}
public static implicit operator String(ResultCode resultCode) => resultCode._code;

#endregion

Expand All @@ -28,7 +27,7 @@ public static implicit operator string(ResultCode resultCode)

#region Constructors

public ResultCode(string code)
public ResultCode(String code)
{
_code = code;
}
Expand All @@ -38,20 +37,11 @@ public ResultCode(string code)

#region Public Methods

public override bool Equals(object obj)
{
return obj != null && string.Equals(this, (ResultCode) obj);
}
public override Boolean Equals(Object obj) => obj != null && String.Equals(this, (ResultCode) obj);

public override int GetHashCode()
{
return _code.GetHashCode();
}
public override Int32 GetHashCode() => _code.GetHashCode();

public override string ToString()
{
return _code;
}
public override String ToString() => _code;

#endregion
}
Expand Down
10 changes: 6 additions & 4 deletions src/YuckQi.Domain.Validation/ResultDetail.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace YuckQi.Domain.Validation
using System;

namespace YuckQi.Domain.Validation
{
public class ResultDetail
{
Expand All @@ -12,17 +14,17 @@ public class ResultDetail
#region Properties

public ResultMessage Message { get; }
public string Property { get; }
public String Property { get; }
public ResultType Type { get; }

public string Code => _code;
public String Code => _code;

#endregion


#region Constructors

public ResultDetail(ResultCode code, ResultMessage message, string property = null, ResultType type = ResultType.Error)
public ResultDetail(ResultCode code, ResultMessage message, String property = null, ResultType type = ResultType.Error)
{
_code = code;

Expand Down
10 changes: 6 additions & 4 deletions src/YuckQi.Domain.Validation/ResultMessage.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
namespace YuckQi.Domain.Validation
using System;

namespace YuckQi.Domain.Validation
{
public readonly struct ResultMessage
{
#region Properties

public string Id { get; }
public string Text { get; }
public String Id { get; }
public String Text { get; }

#endregion


#region Constructors

public ResultMessage(string id, string text = null)
public ResultMessage(String id, String text = null)
{
Id = id;
Text = text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.4.9</Version>
<Version>0.5.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>A .NET library providing domain validation fundamentals.</Description>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/YuckQi.Domain/Aspects/Abstract/IType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace YuckQi.Domain.Aspects.Abstract
public interface IType
{
Guid Identifier { get; set; }
string Name { get; set; }
string ShortName { get; set; }
String Name { get; set; }
String ShortName { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using YuckQi.Domain.Entities.Abstract;
using System;
using YuckQi.Domain.Entities.Abstract;

namespace YuckQi.Domain.Entities.MultiTenant.Abstract
{
public interface IMultiTenantEntity<TKey, TTenantKey> : IEntity<TKey> where TKey : struct where TTenantKey : struct
{
TTenantKey TenantId { get; set; }

bool IsValidTenant(TTenantKey? tenantId);
Boolean IsValidTenant(TTenantKey? tenantId);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using YuckQi.Domain.Entities.Abstract;
using System;
using YuckQi.Domain.Entities.Abstract;

namespace YuckQi.Domain.Entities.MultiTenant.Abstract
{
public abstract class MultiTenantEntityBase<TKey, TTenantKey> : EntityBase<TKey>, IMultiTenantEntity<TKey, TTenantKey> where TKey : struct where TTenantKey : struct
{
public TTenantKey TenantId { get; set; }

public bool IsValidTenant(TTenantKey? tenantId)
{
return TenantId.Equals(tenantId);
}
public Boolean IsValidTenant(TTenantKey? tenantId) => TenantId.Equals(tenantId);
}
}
9 changes: 5 additions & 4 deletions src/YuckQi.Domain/ValueObjects/Abstract/IPage.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace YuckQi.Domain.ValueObjects.Abstract
{
public interface IPage
{
int PageNumber { get; }
int PageSize { get; }
Int32 PageNumber { get; }
Int32 PageSize { get; }
}

public interface IPage<out T> : IPage
{
IReadOnlyCollection<T> Items { get; }
int TotalCount { get; }
Int32 TotalCount { get; }
}
}
4 changes: 2 additions & 2 deletions src/YuckQi.Domain/ValueObjects/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ THE SOFTWARE.
namespace YuckQi.Domain.ValueObjects
{
[Serializable]
public struct Date : IComparable, IFormattable, ISerializable, IComparable<Date>, IEquatable<Date>
public readonly struct Date : IComparable, IFormattable, ISerializable, IComparable<Date>, IEquatable<Date>
{
private DateTime _value;
private readonly DateTime _value;

public static readonly Date MaxValue = new Date(DateTime.MaxValue);
public static readonly Date MinValue = new Date(DateTime.MinValue);
Expand Down
17 changes: 9 additions & 8 deletions src/YuckQi.Domain/ValueObjects/Page.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using YuckQi.Domain.ValueObjects.Abstract;

namespace YuckQi.Domain.ValueObjects
Expand All @@ -7,15 +8,15 @@ namespace YuckQi.Domain.ValueObjects
{
#region Properties

public int PageNumber { get; }
public int PageSize { get; }
public Int32 PageNumber { get; }
public Int32 PageSize { get; }

#endregion


#region Constructors

public Page(int page, int size)
public Page(Int32 page, Int32 size)
{
PageNumber = page;
PageSize = size;
Expand All @@ -29,16 +30,16 @@ public Page(int page, int size)
#region Properties

public IReadOnlyCollection<T> Items { get; }
public int PageNumber { get; }
public int PageSize { get; }
public int TotalCount { get; }
public Int32 PageNumber { get; }
public Int32 PageSize { get; }
public Int32 TotalCount { get; }

#endregion


#region Constructors

public Page(IReadOnlyCollection<T> items, int total, int page, int size)
public Page(IReadOnlyCollection<T> items, Int32 total, Int32 page, Int32 size)
{
Items = items ?? new List<T>();
PageNumber = page;
Expand Down
4 changes: 2 additions & 2 deletions src/YuckQi.Domain/YuckQi.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.4.9</Version>
<Version>0.5.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>A .NET library for bootstrapping a domain model project.</Description>
</PropertyGroup>
Expand Down

0 comments on commit ea792ca

Please sign in to comment.