Skip to content

Commit 9373079

Browse files
authored
Merge pull request #7 from I-RzR-I/feature/ImplementClassDetectPropChanged
Add fluent extensions. Reorganize some classes in the project.
2 parents 49e1eb1 + a307808 commit 9373079

File tree

10 files changed

+323
-14
lines changed

10 files changed

+323
-14
lines changed

docs/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
-> Add few tests.<br/>
1010
-> Adjust usage.<br/>
1111
### **1.0.5.0555**
12-
-> Add validation on ctor attribute input param.<br/>
12+
-> Add validation on ctor attribute input param.<br/>
13+
### **1.0.6.2158**
14+
-> Add fluent extensions to access available methods for save save string properties.<br/>
15+
-> Reorganize some classes in the project.<br/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ***********************************************************************
2+
// Assembly : RzR.Shared.Entity.EntityMaxLengthTrim
3+
// Author : RzR
4+
// Created On : 2023-10-06 22:31
5+
//
6+
// Last Modified By : RzR
7+
// Last Modified On : 2023-10-07 00:54
8+
// ***********************************************************************
9+
// <copyright file="FluentExtensions.cs" company="">
10+
// Copyright (c) RzR. All rights reserved.
11+
// </copyright>
12+
//
13+
// <summary>
14+
// </summary>
15+
// ***********************************************************************
16+
17+
#region U S A G E S
18+
19+
using System.Collections.Generic;
20+
using EntityMaxLengthTrim.Interceptors;
21+
using EntityMaxLengthTrim.Options;
22+
23+
#endregion
24+
25+
namespace EntityMaxLengthTrim.Extensions
26+
{
27+
/// <summary>
28+
/// Fluent extensions for safe store object
29+
/// </summary>
30+
public static class FluentExtensions
31+
{
32+
/// <summary>
33+
/// Prepare initialized object to save store string properties.
34+
/// </summary>
35+
/// <param name="initSourceObject">Required. Initialized object with data.</param>
36+
/// <param name="useDotOnEnd">
37+
/// Optional. The default value is false. If set to <see langword="true" />, then ant the end of
38+
/// string prop will be '...'; otherwise, truncate to max length.
39+
/// </param>
40+
/// <returns></returns>
41+
/// <typeparam name="TEntity">Type of initialized object.</typeparam>
42+
/// <remarks></remarks>
43+
public static TEntity ToSafeStoreStrings<TEntity>(this TEntity initSourceObject, bool useDotOnEnd = false)
44+
where TEntity : class
45+
{
46+
return StringInterceptor.ApplyStringMaxAllowedLength(initSourceObject, useDotOnEnd);
47+
}
48+
49+
50+
/// <summary>
51+
/// Prepare initialized object to save store string properties.
52+
/// </summary>
53+
/// <param name="initSourceObject">Required. Initialized object with data.</param>
54+
/// <param name="truncateWithDots">
55+
/// Required. The default value is false. If set to <see langword="true" />, then ant the end of
56+
/// string prop will be '...'; otherwise, truncate to max length.
57+
/// </param>
58+
/// <param name="processOnlyAssigned">
59+
/// Optional. The default value is false.If set to <see langword="true" />, then
60+
/// process only specified props; otherwise, process all props.
61+
/// </param>
62+
/// <returns></returns>
63+
/// <typeparam name="TEntity">Type of initialized object.</typeparam>
64+
/// <remarks></remarks>
65+
public static TEntity ToSafeStoreStrings<TEntity>(this TEntity initSourceObject,
66+
IReadOnlyCollection<string> truncateWithDots,
67+
bool processOnlyAssigned = false) where TEntity : class
68+
{
69+
return StringInterceptor.ApplyStringMaxAllowedLength(initSourceObject, truncateWithDots,
70+
processOnlyAssigned);
71+
}
72+
73+
/// <summary>
74+
/// Prepare initialized object to save store string properties.
75+
/// </summary>
76+
/// <param name="initSourceObject">Required. Initialized object with data.</param>
77+
/// <param name="options">Required. Properties options</param>
78+
/// <param name="processOnlyAssigned">
79+
/// Optional. The default value is false.If set to <see langword="true" />, then
80+
/// process only specified props; otherwise, process all props.
81+
/// </param>
82+
/// <returns></returns>
83+
/// <typeparam name="TEntity">Type of initialized object.</typeparam>
84+
/// <remarks></remarks>
85+
public static TEntity ToSafeStoreStrings<TEntity>(this TEntity initSourceObject,
86+
IReadOnlyCollection<PropertyOption> options,
87+
bool processOnlyAssigned = false) where TEntity : class
88+
{
89+
return StringInterceptor.ApplyStringMaxAllowedLength(initSourceObject, options, processOnlyAssigned);
90+
}
91+
}
92+
}

src/EntityMaxLengthTrim/Helpers/StringMaxAllowedLengthHelper.cs src/EntityMaxLengthTrim/Extensions/StringMaxAllowedLengthExtensions.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Last Modified By : RzR
77
// Last Modified On : 2022-09-24 03:34
88
// ***********************************************************************
9-
// <copyright file="StringMaxAllowedLengthHelper.cs" company="">
9+
// <copyright file="StringMaxAllowedLengthExtensions.cs" company="">
1010
// Copyright (c) RzR. All rights reserved.
1111
// </copyright>
1212
//
@@ -16,26 +16,26 @@
1616

1717
#region U S A G E S
1818

19-
#if DEBUG
2019
using System;
20+
using System.ComponentModel.DataAnnotations;
2121
using System.Diagnostics;
22+
using System.Linq;
23+
using EntityMaxLengthTrim.Attributes;
24+
#if DEBUG
2225
#endif
23-
using System.ComponentModel.DataAnnotations;
2426
#if NETSTANDARD1_5
2527
using System.Reflection;
2628
#endif
27-
using System.Linq;
28-
using EntityMaxLengthTrim.Attributes;
2929

3030
#endregion
3131

32-
namespace EntityMaxLengthTrim.Helpers
32+
namespace EntityMaxLengthTrim.Extensions
3333
{
3434
/// <summary>
35-
/// Maximum allowed length for string type helper
35+
/// Maximum allowed length for string type extensions
3636
/// </summary>
3737
/// <remarks></remarks>
38-
internal static class StringMaxAllowedLengthHelper
38+
internal static class StringMaxAllowedLengthExtensions
3939
{
4040
/// <summary>
4141
/// Get the maximum allowed length for string property

src/EntityMaxLengthTrim/Interceptors/StringInterceptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using System.Collections.Generic;
2020
using System.Linq;
2121
using EntityMaxLengthTrim.Extensions;
22-
using EntityMaxLengthTrim.Helpers;
2322
using EntityMaxLengthTrim.Options;
2423

2524
#endregion

src/shared/GeneralAssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
#if NETSTANDARD1_6_OR_GREATER || NET35_OR_GREATER
4444
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
4545
#endif
46-
[assembly: AssemblyVersion("1.0.5.0555")]
47-
[assembly: AssemblyFileVersion("1.0.5.0555")]
48-
[assembly: AssemblyInformationalVersion("1.0.5.x")]
46+
[assembly: AssemblyVersion("1.0.6.2158")]
47+
[assembly: AssemblyFileVersion("1.0.6.2158")]
48+
[assembly: AssemblyInformationalVersion("1.0.6.x")]

src/tests/ConsoleCoreTest/ConsoleCoreTest.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
<ProjectReference Include="..\..\EntityMaxLengthTrim\EntityMaxLengthTrim.csproj" />
1010
</ItemGroup>
1111

12+
<ProjectExtensions><VisualStudio><UserProperties BuildVersion_StartDate="2000/1/1" /></VisualStudio></ProjectExtensions>
13+
1214
</Project>

src/tests/ConsoleFramework45Test/ConsoleFramework45Test.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@
5555
<None Include="App.config" />
5656
</ItemGroup>
5757
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
58+
<ProjectExtensions>
59+
<VisualStudio>
60+
<UserProperties BuildVersion_StartDate="2000/1/1" />
61+
</VisualStudio>
62+
</ProjectExtensions>
5863
</Project>

src/tests/ConsoleFrameworkTest/ConsoleFrameworkTest.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@
6161
<None Include="packages.config" />
6262
</ItemGroup>
6363
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
64+
<ProjectExtensions>
65+
<VisualStudio>
66+
<UserProperties BuildVersion_StartDate="2000/1/1" />
67+
</VisualStudio>
68+
</ProjectExtensions>
6469
</Project>

src/tests/EntityModelStringTruncateTest/EntityModelStringTruncateTest.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
@@ -17,4 +17,6 @@
1717
<ProjectReference Include="..\..\EntityMaxLengthTrim\EntityMaxLengthTrim.csproj" />
1818
</ItemGroup>
1919

20+
<ProjectExtensions><VisualStudio><UserProperties BuildVersion_StartDate="2000/1/1" /></VisualStudio></ProjectExtensions>
21+
2022
</Project>

0 commit comments

Comments
 (0)