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.
DataPortalMethodInfo.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalMethodInfo.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Linq;
10using System.Reflection;
11
12namespace Csla.Server
13{
14 internal class DataPortalMethodInfo
15 {
16 public bool RunLocal { get; private set; }
17#if !(ANDROID || IOS) && !NETFX_CORE
18 public TransactionalAttribute TransactionalAttribute { get; private set; }
19#else
20 public TransactionalTypes TransactionalType { get; private set; }
21#endif
22
23 public DataPortalMethodInfo()
24 {
25#if !(ANDROID || IOS) && !NETFX_CORE
26 TransactionalAttribute = new TransactionalAttribute(TransactionalTypes.Manual);
27#else
28 TransactionalType = TransactionalTypes.Manual;
29#endif
30
31 }
32
33 public DataPortalMethodInfo(System.Reflection.MethodInfo info)
34 : this()
35 {
36 if (info != null)
37 {
38 RunLocal = IsRunLocal(info);
39#if !(ANDROID || IOS) && !NETFX_CORE
40 TransactionalAttribute = GetTransactionalAttribute(info);
41#else
42 TransactionalType = TransactionalTypes.Manual;
43#endif
44 }
45 }
46
47 private static bool IsRunLocal(System.Reflection.MethodInfo method)
48 {
49#if NETFX_CORE
50 return method.CustomAttributes.Count(r => r.AttributeType.Equals(typeof(RunLocalAttribute))) > 0;
51#else
52 return Attribute.IsDefined(method, typeof(RunLocalAttribute), false);
53#endif
54 }
55
56#if !(ANDROID || IOS) && !NETFX_CORE
57 private static bool IsTransactionalMethod(System.Reflection.MethodInfo method)
58 {
59 return Attribute.IsDefined(method, typeof(TransactionalAttribute));
60 }
61
62 private static TransactionalAttribute GetTransactionalAttribute(System.Reflection.MethodInfo method)
63 {
64 TransactionalAttribute result;
65 if (IsTransactionalMethod(method))
66 {
67 result =
68 (TransactionalAttribute)Attribute.GetCustomAttribute(
69 method, typeof(TransactionalAttribute));
70 }
71 else
72 result = new TransactionalAttribute(TransactionalTypes.Manual);
73 return result;
74 }
75#endif
76 }
77}
TransactionalTypes
Provides a list of possible transactional technologies to be used by the server-side DataPortal.