Beispiel #1
0
        protected void AddMethodIfNecessary(ConversationalMetaInfoHolder holder, MethodInfo method, IPersistenceConversationInfo info)
        {
            IPersistenceConversationInfo toAdd = null;

            if (info != null)
            {
                if (!info.Exclude)
                {
                    toAdd = info;
                }
            }
            else
            {
                if (holder.Setting.MethodsIncludeMode == MethodsIncludeMode.Implicit)
                {
                    toAdd = new PersistenceConversationAttribute();
                }
            }
            if (toAdd != null && toAdd.ConversationEndMode == EndMode.Unspecified)
            {
                toAdd.ConversationEndMode = holder.Setting.DefaultEndMode;
            }
            if (toAdd != null)
            {
                holder.AddMethodInfo(method, toAdd);
            }
        }
		protected void AddMethodIfNecessary(ConversationalMetaInfoHolder holder, MethodInfo method, IPersistenceConversationInfo info)
		{
			IPersistenceConversationInfo toAdd = null;
			if (info != null)
			{
				if (!info.Exclude)
				{
					toAdd = info;
				}
			}
			else
			{
				if (holder.Setting.MethodsIncludeMode == MethodsIncludeMode.Implicit)
				{
					toAdd = new PersistenceConversationAttribute();
				}
			}
			if (toAdd != null && toAdd.ConversationEndMode == EndMode.Unspecified)
			{
				toAdd.ConversationEndMode = holder.Setting.DefaultEndMode;
			}
			if(toAdd != null)
			{
				holder.AddMethodInfo(method, toAdd);
			}
		}
Beispiel #3
0
        protected virtual void AfterMethodExecution(MethodInfo methodInfo)
        {
            IPersistenceConversationInfo att = Metadata.GetConversationInfoFor(methodInfo);
            var cca = ConversationsContainerAccessor;

            if (att == null || cca == null)
            {
                return;
            }
            IConversation c = cca.Container.Get(conversationId);

            switch (att.ConversationEndMode)
            {
            case EndMode.End:
                c.End();
                c.Dispose();
                break;

            case EndMode.Abort:
                c.Abort();
                c.Dispose();
                break;

            case EndMode.CommitAndContinue:
                c.FlushAndPause();
                break;

            case EndMode.DoNothing:
                break;

            default:
                c.Pause();
                break;
            }
        }
Beispiel #4
0
        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();
            }
        }
		/// <summary>
		/// Add a method info.
		/// </summary>
		/// <param name="methodInfo">The method.</param>
		/// <param name="persistenceConversationInfo">The method settings</param>
		/// <exception cref="ArgumentNullException">When <paramref name="methodInfo"/> is null.</exception>
		/// <exception cref="ArgumentNullException">When <paramref name="persistenceConversationInfo"/> is null.</exception>
		public void AddMethodInfo(MethodInfo methodInfo, IPersistenceConversationInfo persistenceConversationInfo)
		{
			if (methodInfo == null)
			{
				throw new ArgumentNullException("methodInfo");
			}
			if (persistenceConversationInfo == null)
			{
				throw new ArgumentNullException("persistenceConversationInfo");
			}

			lock (locker)
			{
				info[methodInfo] = persistenceConversationInfo;
			}
		}
        /// <summary>
        /// Add a method info.
        /// </summary>
        /// <param name="methodInfo">The method.</param>
        /// <param name="persistenceConversationInfo">The method settings</param>
        /// <exception cref="ArgumentNullException">When <paramref name="methodInfo"/> is null.</exception>
        /// <exception cref="ArgumentNullException">When <paramref name="persistenceConversationInfo"/> is null.</exception>
        public void AddMethodInfo(MethodInfo methodInfo, IPersistenceConversationInfo persistenceConversationInfo)
        {
            if (methodInfo == null)
            {
                throw new ArgumentNullException("methodInfo");
            }
            if (persistenceConversationInfo == null)
            {
                throw new ArgumentNullException("persistenceConversationInfo");
            }

            lock (locker)
            {
                info[methodInfo] = persistenceConversationInfo;
            }
        }