CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
IMethodSymbolExtensions.cs
Go to the documentation of this file.
1using System.Linq;
2using Microsoft.CodeAnalysis;
3
5{
6 internal static class IMethodSymbolExtensions
7 {
8 internal static bool IsPropertyInfoManagementMethod(this IMethodSymbol @this)
9 {
10 return @this != null &&
11 ((@this.ContainingType.Name == CslaMemberConstants.Types.BusinessBase &&
12 (@this.Name == CslaMemberConstants.Properties.SetProperty ||
13 @this.Name == CslaMemberConstants.Properties.SetPropertyConvert)) ||
14 ((@this.ContainingType.Name == CslaMemberConstants.Types.BusinessBase ||
15 @this.ContainingType.Name == CslaMemberConstants.Types.ReadOnlyBase) &&
16 (@this.Name == CslaMemberConstants.Properties.GetProperty ||
17 @this.Name == CslaMemberConstants.Properties.GetPropertyConvert ||
18 @this.Name == CslaMemberConstants.Properties.LazyGetProperty ||
19 @this.Name == CslaMemberConstants.Properties.LazyGetPropertyAsync ||
20 @this.Name == CslaMemberConstants.Properties.LazyReadProperty ||
21 @this.Name == CslaMemberConstants.Properties.LazyReadPropertyAsync ||
22 @this.Name == CslaMemberConstants.Properties.LoadPropertyAsync)) ||
23 ((@this.ContainingType.Name == CslaMemberConstants.Types.BusinessBase ||
24 @this.ContainingType.Name == CslaMemberConstants.Types.ManagedObjectBase) &&
25 @this.Name == CslaMemberConstants.Properties.LoadPropertyMarkDirty) ||
26 ((@this.ContainingType.Name == CslaMemberConstants.Types.BusinessBase ||
27 @this.ContainingType.Name == CslaMemberConstants.Types.ReadOnlyBase ||
28 @this.ContainingType.Name == CslaMemberConstants.Types.ManagedObjectBase) &&
29 (@this.Name == CslaMemberConstants.Properties.ReadProperty ||
30 @this.Name == CslaMemberConstants.Properties.ReadPropertyConvert ||
31 @this.Name == CslaMemberConstants.Properties.LoadProperty ||
32 @this.Name == CslaMemberConstants.Properties.LoadPropertyConvert)));
33 }
34
35 internal static DataPortalOperationQualification IsDataPortalOperation(this IMethodSymbol @this)
36 {
37 return @this is null ? new DataPortalOperationQualification() :
38 @this.IsRootDataPortalOperation().Combine(@this.IsChildDataPortalOperation());
39 }
40
41 internal static DataPortalOperationQualification IsRootDataPortalOperation(this IMethodSymbol @this)
42 {
43 if (@this is null)
44 {
45 return new DataPortalOperationQualification();
46 }
47 else
48 {
49 var byNamingConvention =
50 @this.Name == CslaMemberConstants.Operations.DataPortalCreate ||
51 @this.Name == CslaMemberConstants.Operations.DataPortalFetch ||
52 @this.Name == CslaMemberConstants.Operations.DataPortalInsert ||
53 @this.Name == CslaMemberConstants.Operations.DataPortalUpdate ||
54 @this.Name == CslaMemberConstants.Operations.DataPortalDelete ||
55 @this.Name == CslaMemberConstants.Operations.DataPortalDeleteSelf ||
56 @this.Name == CslaMemberConstants.Operations.DataPortalExecute;
57 var byAttribute = @this.GetAttributes().Any(_ => _.AttributeClass.IsDataPortalRootOperationAttribute());
58 return new DataPortalOperationQualification(byNamingConvention, byAttribute);
59 }
60 }
61
62 internal static DataPortalOperationQualification IsChildDataPortalOperation(this IMethodSymbol @this)
63 {
64 if (@this is null)
65 {
66 return new DataPortalOperationQualification();
67 }
68 else
69 {
70 var byNamingConvention =
71 @this.Name == CslaMemberConstants.Operations.ChildCreate ||
72 @this.Name == CslaMemberConstants.Operations.ChildFetch ||
73 @this.Name == CslaMemberConstants.Operations.ChildInsert ||
74 @this.Name == CslaMemberConstants.Operations.ChildUpdate ||
75 @this.Name == CslaMemberConstants.Operations.ChildDeleteSelf ||
76 @this.Name == CslaMemberConstants.Operations.ChildExecute;
77 var byAttribute = @this.GetAttributes().Any(_ => _.AttributeClass.IsDataPortalChildOperationAttribute());
78 return new DataPortalOperationQualification(byNamingConvention, byAttribute);
79 }
80 }
81 }
82}