1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
.Facilities
.ActiveRecordIntegration
17 using Castle
.ActiveRecord
;
18 using Castle
.Services
.Transaction
;
19 using TransactionMode
= Castle
.Services
.Transaction
.TransactionMode
;
21 public class TransactionScopeResourceAdapter
: IResource
23 private readonly TransactionMode transactionMode
;
24 private TransactionScope scope
;
27 /// Initializes a new instance of the <see cref="TransactionScopeResourceAdapter"/> class.
29 /// <param name="transactionMode">The transaction mode.</param>
30 public TransactionScopeResourceAdapter(TransactionMode transactionMode
)
32 this.transactionMode
= transactionMode
;
37 Castle
.ActiveRecord
.TransactionMode mode
= (transactionMode
== TransactionMode
.Requires
)
38 ? Castle
.ActiveRecord
.TransactionMode
.Inherits
39 : Castle
.ActiveRecord
.TransactionMode
.New
;
41 scope
= new TransactionScope(mode
);
51 public void Rollback()
58 protected void Dispose()