Skip to content

Commit ebf2a18

Browse files
committed
Add methods in the base class to set variables to default value.
1 parent ece6c5b commit ebf2a18

2 files changed

Lines changed: 156 additions & 3 deletions

File tree

src/TryToExecute/CodeExec/TryCatchExecuteBase.cs

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created On : 2024-12-04 14:52
55
//
66
// Last Modified By : RzR
7-
// Last Modified On : 2024-12-04 14:53
7+
// Last Modified On : 2025-01-16 21:52
88
// ***********************************************************************
99
// <copyright file="TryCatchExecuteBase.cs" company="RzR SOFT & TECH">
1010
// Copyright © RzR. All rights reserved.
@@ -14,14 +14,92 @@
1414
// </summary>
1515
// ***********************************************************************
1616

17+
#region U S A G E S
18+
19+
using TryToExecute.Helpers;
20+
21+
#endregion
22+
1723
namespace TryToExecute.CodeExec
1824
{
1925
/// -------------------------------------------------------------------------------------------------
26+
/// <summary>
27+
/// A try catch execute base.
28+
/// </summary>
2029
/// <content>
2130
/// A try catch execute base.
2231
/// </content>
2332
/// =================================================================================================
2433
public abstract partial class TryCatchExecuteBase
2534
{
35+
/// -------------------------------------------------------------------------------------------------
36+
/// <summary>
37+
/// Sets to default if present.
38+
/// </summary>
39+
/// <typeparam name="T1">Generic type parameter.</typeparam>
40+
/// <param name="item">[in,out] The item.</param>
41+
/// =================================================================================================
42+
protected virtual void SetToDefaultIfPresent<T1>(ref T1 item)
43+
=> RefTypeParamHelper.ToDefaultValue(ref item);
44+
45+
/// -------------------------------------------------------------------------------------------------
46+
/// <summary>
47+
/// Sets to default if present.
48+
/// </summary>
49+
/// <typeparam name="T1">Generic type parameter.</typeparam>
50+
/// <typeparam name="T2">Generic type parameter.</typeparam>
51+
/// <param name="item1">[in,out] The first item.</param>
52+
/// <param name="item2">[in,out] The second item.</param>
53+
/// =================================================================================================
54+
protected virtual void SetToDefaultIfPresent<T1, T2>(ref T1 item1, ref T2 item2)
55+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2);
56+
57+
/// -------------------------------------------------------------------------------------------------
58+
/// <summary>
59+
/// Sets to default if present.
60+
/// </summary>
61+
/// <typeparam name="T1">Generic type parameter.</typeparam>
62+
/// <typeparam name="T2">Generic type parameter.</typeparam>
63+
/// <typeparam name="T3">Generic type parameter.</typeparam>
64+
/// <param name="item1">[in,out] The first item.</param>
65+
/// <param name="item2">[in,out] The second item.</param>
66+
/// <param name="item3">[in,out] The third item.</param>
67+
/// =================================================================================================
68+
protected virtual void SetToDefaultIfPresent<T1, T2, T3>(ref T1 item1, ref T2 item2, ref T3 item3)
69+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3);
70+
71+
/// -------------------------------------------------------------------------------------------------
72+
/// <summary>
73+
/// Sets to default if present.
74+
/// </summary>
75+
/// <typeparam name="T1">Generic type parameter.</typeparam>
76+
/// <typeparam name="T2">Generic type parameter.</typeparam>
77+
/// <typeparam name="T3">Generic type parameter.</typeparam>
78+
/// <typeparam name="T4">Generic type parameter.</typeparam>
79+
/// <param name="item1">[in,out] The first item.</param>
80+
/// <param name="item2">[in,out] The second item.</param>
81+
/// <param name="item3">[in,out] The third item.</param>
82+
/// <param name="item4">[in,out] The fourth item.</param>
83+
/// =================================================================================================
84+
protected virtual void SetToDefaultIfPresent<T1, T2, T3, T4>(ref T1 item1, ref T2 item2, ref T3 item3, ref T4 item4)
85+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3, ref item4);
86+
87+
/// -------------------------------------------------------------------------------------------------
88+
/// <summary>
89+
/// Sets to default if present.
90+
/// </summary>
91+
/// <typeparam name="T1">Generic type parameter.</typeparam>
92+
/// <typeparam name="T2">Generic type parameter.</typeparam>
93+
/// <typeparam name="T3">Generic type parameter.</typeparam>
94+
/// <typeparam name="T4">Generic type parameter.</typeparam>
95+
/// <typeparam name="T5">Generic type parameter.</typeparam>
96+
/// <param name="item1">[in,out] The first item.</param>
97+
/// <param name="item2">[in,out] The second item.</param>
98+
/// <param name="item3">[in,out] The third item.</param>
99+
/// <param name="item4">[in,out] The fourth item.</param>
100+
/// <param name="item5">[in,out] The fourth item.</param>
101+
/// =================================================================================================
102+
protected virtual void SetToDefaultIfPresent<T1, T2, T3, T4, T5>(ref T1 item1, ref T2 item2, ref T3 item3, ref T4 item4, ref T5 item5)
103+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3, ref item4, ref item5);
26104
}
27105
}

src/TryToExecute/CodeExec/TryCatchExecuteStaticBase.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// ***********************************************************************
22
// Assembly : RzR.Shared.Extensions.TryToExecute
33
// Author : RzR
4-
// Created On : 2024-12-04 14:53
4+
// Created On : 2024-12-04 20:49
55
//
66
// Last Modified By : RzR
7-
// Last Modified On : 2024-12-04 14:53
7+
// Last Modified On : 2025-01-20 15:43
88
// ***********************************************************************
99
// <copyright file="TryCatchExecuteStaticBase.cs" company="RzR SOFT & TECH">
1010
// Copyright © RzR. All rights reserved.
@@ -14,6 +14,12 @@
1414
// </summary>
1515
// ***********************************************************************
1616

17+
#region U S A G E S
18+
19+
using TryToExecute.Helpers;
20+
21+
#endregion
22+
1723
namespace TryToExecute.CodeExec
1824
{
1925
/// -------------------------------------------------------------------------------------------------
@@ -23,5 +29,74 @@ namespace TryToExecute.CodeExec
2329
/// =================================================================================================
2430
public partial class TryCatchExecuteStaticBase
2531
{
32+
/// -------------------------------------------------------------------------------------------------
33+
/// <summary>
34+
/// Sets to default if present.
35+
/// </summary>
36+
/// <typeparam name="T1">Generic type parameter.</typeparam>
37+
/// <param name="item">[in,out] The item.</param>
38+
/// =================================================================================================
39+
protected static void SetToDefaultIfPresent<T1>(ref T1 item)
40+
=> RefTypeParamHelper.ToDefaultValue(ref item);
41+
42+
/// -------------------------------------------------------------------------------------------------
43+
/// <summary>
44+
/// Sets to default if present.
45+
/// </summary>
46+
/// <typeparam name="T1">Generic type parameter.</typeparam>
47+
/// <typeparam name="T2">Generic type parameter.</typeparam>
48+
/// <param name="item1">[in,out] The first item.</param>
49+
/// <param name="item2">[in,out] The second item.</param>
50+
/// =================================================================================================
51+
protected static void SetToDefaultIfPresent<T1, T2>(ref T1 item1, ref T2 item2)
52+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2);
53+
54+
/// -------------------------------------------------------------------------------------------------
55+
/// <summary>
56+
/// Sets to default if present.
57+
/// </summary>
58+
/// <typeparam name="T1">Generic type parameter.</typeparam>
59+
/// <typeparam name="T2">Generic type parameter.</typeparam>
60+
/// <typeparam name="T3">Generic type parameter.</typeparam>
61+
/// <param name="item1">[in,out] The first item.</param>
62+
/// <param name="item2">[in,out] The second item.</param>
63+
/// <param name="item3">[in,out] The third item.</param>
64+
/// =================================================================================================
65+
protected static void SetToDefaultIfPresent<T1, T2, T3>(ref T1 item1, ref T2 item2, ref T3 item3)
66+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3);
67+
68+
/// -------------------------------------------------------------------------------------------------
69+
/// <summary>
70+
/// Sets to default if present.
71+
/// </summary>
72+
/// <typeparam name="T1">Generic type parameter.</typeparam>
73+
/// <typeparam name="T2">Generic type parameter.</typeparam>
74+
/// <typeparam name="T3">Generic type parameter.</typeparam>
75+
/// <typeparam name="T4">Generic type parameter.</typeparam>
76+
/// <param name="item1">[in,out] The first item.</param>
77+
/// <param name="item2">[in,out] The second item.</param>
78+
/// <param name="item3">[in,out] The third item.</param>
79+
/// <param name="item4">[in,out] The fourth item.</param>
80+
/// =================================================================================================
81+
protected static void SetToDefaultIfPresent<T1, T2, T3, T4>(ref T1 item1, ref T2 item2, ref T3 item3, ref T4 item4)
82+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3, ref item4);
83+
84+
/// -------------------------------------------------------------------------------------------------
85+
/// <summary>
86+
/// Sets to default if present.
87+
/// </summary>
88+
/// <typeparam name="T1">Generic type parameter.</typeparam>
89+
/// <typeparam name="T2">Generic type parameter.</typeparam>
90+
/// <typeparam name="T3">Generic type parameter.</typeparam>
91+
/// <typeparam name="T4">Generic type parameter.</typeparam>
92+
/// <typeparam name="T5">Generic type parameter.</typeparam>
93+
/// <param name="item1">[in,out] The first item.</param>
94+
/// <param name="item2">[in,out] The second item.</param>
95+
/// <param name="item3">[in,out] The third item.</param>
96+
/// <param name="item4">[in,out] The fourth item.</param>
97+
/// <param name="item5">[in,out] The fourth item.</param>
98+
/// =================================================================================================
99+
protected static void SetToDefaultIfPresent<T1, T2, T3, T4, T5>(ref T1 item1, ref T2 item2, ref T3 item3, ref T4 item4, ref T5 item5)
100+
=> RefTypeParamHelper.ToDefaultValue(ref item1, ref item2, ref item3, ref item4, ref item5);
26101
}
27102
}

0 commit comments

Comments
 (0)