Skip to content

Commit e62885d

Browse files
committed
refactoring : extract Traits to separate files
1 parent 71e51bf commit e62885d

File tree

6 files changed

+679
-655
lines changed

6 files changed

+679
-655
lines changed
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
using NetArchTest.Functions;
2+
3+
namespace NetArchTest.Rules
4+
{
5+
public sealed partial class Condition
6+
{
7+
/// <summary>
8+
/// Selects types that are marked as abstract.
9+
/// </summary>
10+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
11+
public ConditionList BeAbstract()
12+
{
13+
AddFunctionCall(x => FunctionDelegates.BeAbstract(x, true));
14+
return CreateConditionList();
15+
}
16+
17+
/// <summary>
18+
/// Selects types that are not marked as abstract.
19+
/// </summary>
20+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
21+
public ConditionList NotBeAbstract()
22+
{
23+
AddFunctionCall(x => FunctionDelegates.BeAbstract(x, false));
24+
return CreateConditionList();
25+
}
26+
27+
/// <summary>
28+
/// Selects types that are classes.
29+
/// </summary>
30+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
31+
public ConditionList BeClasses()
32+
{
33+
AddFunctionCall(x => FunctionDelegates.BeClass(x, true));
34+
return CreateConditionList();
35+
}
36+
37+
/// <summary>
38+
/// Selects types that are not classes.
39+
/// </summary>
40+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
41+
public ConditionList NotBeClasses()
42+
{
43+
AddFunctionCall(x => FunctionDelegates.BeClass(x, false));
44+
return CreateConditionList();
45+
}
46+
47+
/// <summary>
48+
/// Selects types that have generic parameters.
49+
/// </summary>
50+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
51+
public ConditionList BeGeneric()
52+
{
53+
AddFunctionCall(x => FunctionDelegates.BeGeneric(x, true));
54+
return CreateConditionList();
55+
}
56+
57+
/// <summary>
58+
/// Selects types that do not have generic parameters.
59+
/// </summary>
60+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
61+
public ConditionList NotBeGeneric()
62+
{
63+
AddFunctionCall(x => FunctionDelegates.BeGeneric(x, false));
64+
return CreateConditionList();
65+
}
66+
67+
68+
/// <summary>
69+
/// Selects types that are interfaces.
70+
/// </summary>
71+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
72+
public ConditionList BeInterfaces()
73+
{
74+
AddFunctionCall(x => FunctionDelegates.BeInterface(x, true));
75+
return CreateConditionList();
76+
}
77+
78+
/// <summary>
79+
/// Selects types that are not interfaces.
80+
/// </summary>
81+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
82+
public ConditionList NotBeInterfaces()
83+
{
84+
AddFunctionCall(x => FunctionDelegates.BeInterface(x, false));
85+
return CreateConditionList();
86+
}
87+
88+
/// <summary>
89+
/// Selects types that are static.
90+
/// </summary>
91+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
92+
public ConditionList BeStatic()
93+
{
94+
AddFunctionCall(x => FunctionDelegates.BeStatic(x, true));
95+
return CreateConditionList();
96+
}
97+
98+
/// <summary>
99+
/// Selects types that are not static.
100+
/// </summary>
101+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
102+
public ConditionList NotBeStatic()
103+
{
104+
AddFunctionCall(x => FunctionDelegates.BeStatic(x, false));
105+
return CreateConditionList();
106+
}
107+
108+
/// <summary>
109+
/// Selects types that are nested.
110+
/// </summary>
111+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
112+
public ConditionList BeNested()
113+
{
114+
AddFunctionCall(x => FunctionDelegates.BeNested(x, true));
115+
return CreateConditionList();
116+
}
117+
118+
/// <summary>
119+
/// Selects types that are nested and public.
120+
/// </summary>
121+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
122+
public ConditionList BeNestedPublic()
123+
{
124+
AddFunctionCall(x => FunctionDelegates.BeNestedPublic(x, true));
125+
return CreateConditionList();
126+
}
127+
128+
/// <summary>
129+
/// Selects types that are nested and private.
130+
/// </summary>
131+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
132+
public ConditionList BeNestedPrivate()
133+
{
134+
AddFunctionCall(x => FunctionDelegates.BeNestedPrivate(x, true));
135+
return CreateConditionList();
136+
}
137+
138+
/// <summary>
139+
/// Selects types that are not nested.
140+
/// </summary>
141+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
142+
public ConditionList NotBeNested()
143+
{
144+
AddFunctionCall(x => FunctionDelegates.BeNested(x, false));
145+
return CreateConditionList();
146+
}
147+
148+
/// <summary>
149+
/// Selects types that are not nested and public.
150+
/// </summary>
151+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
152+
public ConditionList NotBeNestedPublic()
153+
{
154+
AddFunctionCall(x => FunctionDelegates.BeNestedPublic(x, false));
155+
return CreateConditionList();
156+
}
157+
158+
/// <summary>
159+
/// Selects types that are not nested and private.
160+
/// </summary>
161+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
162+
public ConditionList NotBeNestedPrivate()
163+
{
164+
AddFunctionCall(x => FunctionDelegates.BeNestedPrivate(x, false));
165+
return CreateConditionList();
166+
}
167+
168+
/// <summary>
169+
/// Selects types that are have public scope.
170+
/// </summary>
171+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
172+
public ConditionList BePublic()
173+
{
174+
AddFunctionCall(x => FunctionDelegates.BePublic(x, true));
175+
return CreateConditionList();
176+
}
177+
178+
/// <summary>
179+
/// Selects types that do not have public scope.
180+
/// </summary>
181+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
182+
public ConditionList NotBePublic()
183+
{
184+
AddFunctionCall(x => FunctionDelegates.BePublic(x, false));
185+
return CreateConditionList();
186+
}
187+
188+
/// <summary>
189+
/// Selects types according that are marked as sealed.
190+
/// </summary>
191+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
192+
public ConditionList BeSealed()
193+
{
194+
AddFunctionCall(x => FunctionDelegates.BeSealed(x, true));
195+
return CreateConditionList();
196+
}
197+
198+
/// <summary>
199+
/// Selects types according that are not marked as sealed.
200+
/// </summary>
201+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
202+
public ConditionList NotBeSealed()
203+
{
204+
AddFunctionCall(x => FunctionDelegates.BeSealed(x, false));
205+
return CreateConditionList();
206+
}
207+
208+
/// <summary>
209+
/// Selects types that are immutable.
210+
/// </summary>
211+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
212+
public ConditionList BeImmutable()
213+
{
214+
AddFunctionCall(x => FunctionDelegates.BeImmutable(x, true));
215+
return CreateConditionList();
216+
}
217+
218+
/// <summary>
219+
/// Selects types that are mutable.
220+
/// </summary>
221+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
222+
public ConditionList BeMutable()
223+
{
224+
AddFunctionCall(x => FunctionDelegates.BeImmutable(x, false));
225+
return CreateConditionList();
226+
}
227+
228+
/// <summary>
229+
/// Selects types according to whether they have nullable members.
230+
/// </summary>
231+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
232+
public ConditionList OnlyHaveNullableMembers()
233+
{
234+
AddFunctionCall(x => FunctionDelegates.HasNullableMembers(x, true));
235+
return CreateConditionList();
236+
}
237+
238+
/// <summary>
239+
/// Selects types according to whether they have nullable members.
240+
/// </summary>
241+
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
242+
public ConditionList HaveSomeNonNullableMembers()
243+
{
244+
AddFunctionCall(x => FunctionDelegates.HasNullableMembers(x, false));
245+
return CreateConditionList();
246+
}
247+
}
248+
}

0 commit comments

Comments
 (0)