protected virtual void BeforeMethodExecution(MethodInfo methodInfo) { IPersistenceConversationInfo att = Metadata.GetConversationInfoFor(methodInfo); var cca = ConversationsContainerAccessor; if (att == null || cca == null) { return; } string convId = GetConvesationId(Metadata.Setting); IConversation c = cca.Container.Get(convId); if (c == null) { var cf = ConversationFactory; if (cf == null) { return; } c = cf.CreateConversation(convId); // we are using the event because a custom eventHandler can prevent the rethrow // but we must Unbind the conversation from the container // and we must dispose the conversation itself (high probability UoW inconsistence). c.OnException += ((conversation, args) => cca.Container.Unbind(c.Id).Dispose()); ConfigureConversation(c); cca.Container.SetAsCurrent(c); c.Start(); } else { cca.Container.SetAsCurrent(c); c.Resume(); } }
protected void EndPersistenceConversation() { IConversation c = cca.Container.Get(GetConvesationId()); if (c != null) { c.Resume(); c.End(); } }
public PersistenceConversationCaregiver(PersistenceConversationalModel pcm, ConversationEndMode endMode) { this.pcm = pcm; this.endMode = endMode; string convId = pcm.GetConvesationId(); IConversation c = pcm.cca.Container.Get(convId) ?? pcm.cf.CreateConversation(convId); pcm.cca.Container.SetAsCurrent(c); c.Resume(); }
public void OnEntry(MethodExecutionArgs eventArgs) { if (IsNoopConversationalMarkerActive) { return; } var convId = GetConversationIdMethod.Invoke(); IConversation c = ConversationsContainerAccessor.Container.Get(convId); if (c == null) { IConversationFactory cf = ConversationFactory; if (cf == null) { return; } c = cf.CreateConversation(convId); // we are using the event because a custom eventHandler can prevent the rethrow // but we must Unbind the conversation from the container // and we must dispose the conversation itself (high probability UoW inconsistence). c.OnException += ((conversation, args) => ConversationsContainerAccessor.Container.Unbind(c.Id).Dispose()); ConfigureConversation(c, eventArgs.Instance); ConversationsContainerAccessor.Container.SetAsCurrent(c); c.Start(); ConversationPausedWatcher.Watch(c); } else { ConversationsContainerAccessor.Container.SetAsCurrent(c); if (ConversationPausedWatcher.IsPaused(c)) { c.Resume(); } else { eventArgs.MethodExecutionTag = NestedMethodMarker; } } }