Added DictionaryAdapter.build.
[castle.git] / Services / Transaction / Castle.Services.Transaction / Attributes.cs
blob36ba85d32c293b2a426d64fa97503a43bb64da61
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Services.Transaction
17 using System;
19 /// <summary>
20 /// The supported transaction mode for the components.
21 /// </summary>
22 public enum TransactionMode
24 /// <summary>
25 ///
26 /// </summary>
27 Unspecified,
28 /// <summary>
29 /// transaction context will be created
30 /// managing internally a connection, no
31 /// transaction is opened though
32 /// </summary>
33 NotSupported,
34 /// <summary>
35 /// transaction context will be created if not present
36 /// </summary>
37 Requires,
38 /// <summary>
39 /// a new transaction context will be created
40 /// </summary>
41 RequiresNew,
42 /// <summary>
43 /// an existing appropriate transaction context
44 /// will be joined if present
45 /// </summary>
46 Supported
49 /// <summary>
50 /// The supported isolation modes.
51 /// </summary>
52 public enum IsolationMode
54 Unspecified,
55 Chaos,
56 ReadCommitted,
57 ReadUncommitted,
58 RepeatableRead,
59 Serializable
62 /// <summary>
63 /// Indicates that the target class wants to use
64 /// the transactional services.
65 /// </summary>
66 [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
67 public class TransactionalAttribute : System.Attribute
71 /// <summary>
72 /// Indicates the transaction support for a method.
73 /// </summary>
74 [AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
75 public class TransactionAttribute : System.Attribute
77 private TransactionMode _transactionMode;
78 private IsolationMode _isolationMode;
79 private bool distributedTransaction;
81 /// <summary>
82 /// Declares unspecified values for transaction and isolation, which
83 /// means that the transaction manager will use the default values
84 /// for them
85 /// </summary>
86 public TransactionAttribute() : this(TransactionMode.Unspecified, IsolationMode.Unspecified)
90 /// <summary>
91 /// Declares the transaction mode, but omits the isolation,
92 /// which means that the transaction manager should use the
93 /// default value for it.
94 /// </summary>
95 /// <param name="transactionMode"></param>
96 public TransactionAttribute(TransactionMode transactionMode) : this(transactionMode, IsolationMode.Unspecified)
100 /// <summary>
101 /// Declares both the transaction mode and isolation
102 /// desired for this method. The transaction manager should
103 /// obey the declaration.
104 /// </summary>
105 /// <param name="transactionMode"></param>
106 /// <param name="isolationMode"></param>
107 public TransactionAttribute(TransactionMode transactionMode, IsolationMode isolationMode)
109 _transactionMode = transactionMode;
110 _isolationMode = isolationMode;
113 /// <summary>
114 /// Returns the <see cref="TransactionMode"/>
115 /// </summary>
116 public TransactionMode TransactionMode
118 get { return _transactionMode; }
121 /// <summary>
122 /// Returns the <see cref="IsolationMode"/>
123 /// </summary>
124 public IsolationMode IsolationMode
126 get { return _isolationMode; }
129 /// <summary>
130 /// Gets or sets a value indicating whether the transaction should be distributed.
131 /// </summary>
132 /// <value>
133 /// <c>true</c> if a distributed transaction should be created; otherwise, <c>false</c>.
134 /// </value>
135 public bool Distributed
137 get { return distributedTransaction; }
138 set { distributedTransaction = value; }