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
+ }
0 commit comments