本文整理汇总了C#中ITransactionContext类的典型用法代码示例。如果您正苦于以下问题:C# ITransactionContext类的具体用法?C# ITransactionContext怎么用?C# ITransactionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITransactionContext类属于命名空间,在下文中一共展示了ITransactionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransactionPropertyNode
/// <summary>
/// Constructor</summary>
public TransactionPropertyNode(ITransactionContext context)
{
if(context != null)
m_contextRef = new WeakReference(context);
else
IsReadOnly = true;
}
示例2: TransactedTask
public TransactedTask(ITask inner, ITransactionContext transactionContext)
{
if (inner == null) throw new ArgumentNullException("inner");
if (transactionContext == null) throw new ArgumentNullException("transactionContext");
_inner = inner;
_transactionContext = transactionContext;
}
示例3: TransactedActionFilter
public TransactedActionFilter(ITransactionContext transactionContext, EventDispatchHandler dispatchHandler, ILocalEventsManager domainEvents)
{
if (transactionContext == null) throw new ArgumentNullException("transactionContext");
_transactionContext = transactionContext;
_dispatchHandler = dispatchHandler;
_domainEvents = domainEvents;
}
示例4: DbLogger
public DbLogger(ITransactionContext context)
{
this.context = context;
Error = new DbLoggerError(this);
Info = new DbLoggerInfo(this);
}
示例5: HandleMessage
public void HandleMessage(TransportMessage transportMessage, ITransactionContext transactionContext)
{
var message = transportMessage.GetMessageLabel();
var options = new List<KeyOption>();
if (DefaultOutputQueue != null)
{
options.Add(KeyOption.New('d',
() => { MoveMessage(transportMessage, transactionContext, DefaultOutputQueue); },
"Move to default queue '{0}'", DefaultOutputQueue));
}
if (transportMessage.Headers.ContainsKey(Headers.SourceQueue))
{
var sourceQueue = transportMessage.Headers[Headers.SourceQueue];
options.Add(KeyOption.New('s',
() => { MoveMessage(transportMessage, transactionContext, sourceQueue); },
"Return to source queue '{0}'", sourceQueue));
}
options.Add(KeyOption.New('c', () =>
{
Console.Write("queue > ");
var queueName = Console.ReadLine();
MoveMessage(transportMessage, transactionContext, queueName);
}, "Enter custom queue name to move message to"));
Prompt(message, options);
Text.PrintLine();
}
示例6: IncomingStepContext
/// <summary>
/// Constructs the step context, initially stashing the given <see cref="TransportMessage"/> and <see cref="ITransactionContext"/> into its bag of objects
/// </summary>
public IncomingStepContext(TransportMessage message, ITransactionContext transactionContext)
{
Save(message);
Save(transactionContext);
transactionContext.Items[StepContextKey] = this;
}
示例7: HandlePoisonMessage
/// <summary>
/// Handles the poisonous message by forwarding it to the configured error queue
/// </summary>
public async Task HandlePoisonMessage(TransportMessage transportMessage, ITransactionContext transactionContext, string errorDescription)
{
var headers = transportMessage.Headers;
string messageId ;
if (!headers.TryGetValue(Headers.MessageId, out messageId))
{
messageId = "<unknown>";
}
headers[Headers.ErrorDetails] = errorDescription;
headers[Headers.SourceQueue] = _transport.Address;
var errorQueueAddress = _simpleRetryStrategySettings.ErrorQueueAddress;
try
{
_log.Error("Moving message with ID {0} to error queue '{1}' - reason: {2}", messageId, errorQueueAddress, errorDescription);
await _transport.Send(errorQueueAddress, transportMessage, transactionContext);
}
catch (Exception exception)
{
_log.Error(exception, "Could not move message with ID {0} to error queue '{1}' - will pause {2} to avoid thrashing",
messageId, errorQueueAddress, MoveToErrorQueueFailedPause);
// if we can't move to error queue, we need to avoid thrashing over and over
await Task.Delay(MoveToErrorQueueFailedPause);
}
}
示例8: Send
public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
{
var outputQueue = cloudQueueClient.GetQueueReference(destinationQueueName);
using (var memoryStream = new MemoryStream())
{
var formatter = new BinaryFormatter();
var receivedTransportMessage = new ReceivedTransportMessage
{
Id = Guid.NewGuid().ToString(),
Headers = message.Headers,
Body = message.Body,
Label = message.Label,
};
formatter.Serialize(memoryStream, receivedTransportMessage);
memoryStream.Position = 0;
var cloudQueueMessage = new CloudQueueMessage(memoryStream.ToArray());
var timeToLive = GetTimeToLive(message);
if (timeToLive.HasValue)
{
outputQueue.AddMessage(cloudQueueMessage, timeToLive.Value);
}
else
{
outputQueue.AddMessage(cloudQueueMessage);
}
}
}
示例9: ReceiveMessage
public ReceivedTransportMessage ReceiveMessage(ITransactionContext context)
{
var receivedTransportMessage = innerReceiveMessages.ReceiveMessage(context);
if (receivedTransportMessage == null) return null;
byte[] body;
var headers = receivedTransportMessage.Headers.Clone();
if (headers.ContainsKey(Headers.Encrypted))
{
var iv = receivedTransportMessage.GetHeader(Headers.EncryptionSalt);
body = helper.Decrypt(receivedTransportMessage.Body, iv);
headers.Remove(Headers.EncryptionSalt);
headers.Remove(Headers.Encrypted);
}
else
{
body = receivedTransportMessage.Body;
}
return new ReceivedTransportMessage
{
Id = receivedTransportMessage.Id,
Headers = headers,
Label = receivedTransportMessage.Label,
Body = body,
};
}
示例10: Send
/// <summary>
/// Sends the given <see cref="TransportMessage"/> to the queue with the specified globally addressable name
/// </summary>
public async Task Send(string destinationAddress, TransportMessage message, ITransactionContext context)
{
context.OnCommitted(async () =>
{
var headers = message.Headers.Clone();
var queue = GetQueue(destinationAddress);
var messageId = Guid.NewGuid().ToString();
var popReceipt = Guid.NewGuid().ToString();
var timeToBeReceivedOrNull = GetTimeToBeReceivedOrNull(headers);
var queueVisibilityDelayOrNull = GetQueueVisibilityDelayOrNull(headers);
var cloudQueueMessage = Serialize(messageId, popReceipt, headers, message.Body);
try
{
var options = new QueueRequestOptions {RetryPolicy = new ExponentialRetry()};
var operationContext = new OperationContext();
await queue.AddMessageAsync(cloudQueueMessage, timeToBeReceivedOrNull, queueVisibilityDelayOrNull, options, operationContext);
}
catch (Exception exception)
{
throw new RebusApplicationException(exception, $"Could not send message with ID {cloudQueueMessage.Id} to '{destinationAddress}'");
}
});
}
示例11: DeleteOrderCommand
public DeleteOrderCommand(long orderID, IOrderDataProxy orderDataProxy, OrderItemService orderItemService, ITransactionContext transactionContext)
{
_orderID = orderID;
_orderDataProxy = orderDataProxy;
_orderItemService = orderItemService;
_transactionContext = transactionContext;
}
示例12: Send
/// <summary>
/// Sends a copy of the specified <see cref="TransportMessageToSend"/> using the underlying implementation of <see cref="ISendMessages"/>
/// with an encrypted message body and additional headers
/// </summary>
public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
{
var clone = new TransportMessageToSend
{
Headers = message.Headers.Clone(),
Label = message.Label,
Body = message.Body,
};
if (compressionHelper != null)
{
var compresssionResult = compressionHelper.Compress(clone.Body);
if (compresssionResult.Item1)
{
clone.Headers[Headers.Compression] = Headers.CompressionTypes.GZip;
}
clone.Body = compresssionResult.Item2;
}
if (encryptionHelper != null)
{
var iv = encryptionHelper.GenerateNewIv();
clone.Body = encryptionHelper.Encrypt(clone.Body, iv);
clone.Headers[Headers.Encrypted] = null;
clone.Headers[Headers.EncryptionSalt] = iv;
}
innerSendMessages.Send(destinationQueueName, clone, context);
}
示例13: Transaction
internal Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation, IEnumerable<TableSource> committedTables, IEnumerable<IIndexSet> indexSets)
{
CommitId = commitId;
Database = database;
Isolation = isolation;
Context = context;
context.RegisterInstance<ITransaction>(this);
Registry = new TransactionRegistry(this);
TableManager.AddVisibleTables(committedTables, indexSets);
AddInternalTables();
TableState = new OldNewTableState();
IsClosed = false;
Database.TransactionFactory.OpenTransactions.AddTransaction(this);
this.CurrentSchema(database.Context.DefaultSchema());
this.ReadOnly(database.Context.ReadOnly());
this.AutoCommit(database.Context.AutoCommit());
this.IgnoreIdentifiersCase(database.Context.IgnoreIdentifiersCase());
this.ParameterStyle(QueryParameterStyle.Marker);
}
示例14: OrderItemClientService
public OrderItemClientService(IOrderItemDataProxy dataProxy,
IProductDataProxy productDataProxy,
IInventoryItemDataProxy inventoryDataProxy,
ITransactionContext transactionContext) : base(dataProxy, productDataProxy, inventoryDataProxy, transactionContext)
{
_inventoryDataProxy = inventoryDataProxy;
_transactionContext = transactionContext;
}
示例15: Send
public async Task Send(string destinationAddress, TransportMessage message, ITransactionContext context)
{
await _innerTransport.Send(destinationAddress, message, context);
_sentMessages.Add(message);
MessageSent(message);
}