1: public class TransactionFormatter
2: {
3: const string OleTxFormatterType = "System.ServiceModel.Transactions.OleTxTransactionFormatter,System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
4: const string Wsat10FormatterType = "System.ServiceModel.Transactions.WsatTransactionFormatter10,System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
5: const string Wsat11FormatterType = "System.ServiceModel.Transactions.WsatTransactionFormatter11,System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
6:
7: public object InternalFormatter
8: { get; private set; }
9:
10: public TransactionFormatter(TransactionProtocol transactionProtocol)
11: {
12: if (transactionProtocol == TransactionProtocol.OleTransactions)
13: {
14: this.InternalFormatter = ReflectUtil.CreateInstance(OleTxFormatterType);
15: }
16: else if (transactionProtocol == TransactionProtocol.WSAtomicTransactionOctober2004)
17: {
18: this.InternalFormatter = ReflectUtil.CreateInstance(Wsat10FormatterType);
19: }
20: else
21: {
22: this.InternalFormatter = ReflectUtil.CreateInstance(Wsat11FormatterType);
23: }
24: }
25:
26: public Transaction ReadTransaction(Message message)
27: {
28: object transInfo = ReflectUtil.Invoke("ReadTransaction", this.InternalFormatter, message);
29: return ReflectUtil.Invoke("UnmarshalTransaction", transInfo) as Transaction;
30: }
31:
32: public void WriteTransaction(Transaction transaction, Message message)
33: {
34: ReflectUtil.Invoke("WriteTransaction", this.InternalFormatter, transaction, message);
35: }
36: }