Esempio n. 1
0
        /// <summary>
        ///     Returns the <see cref="Session" /> implementation of the current open session.
        /// </summary>
        /// <typeparam name="TSession">The type of the session.</typeparam>
        /// <param name="source">The process framework application.</param>
        /// <param name="action">The function that will initialize the session (should be used for custom implementations).</param>
        /// <returns>
        ///     Returns a <see cref="Session" /> representing the session; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">action</exception>
        public static TSession GetSession <TSession>(this IMMPxApplication source, Func <int, IMMPxApplication, TSession> action)
            where TSession : Session
        {
            if (source == null)
            {
                return(null);
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var sm = source.GetSessionManager() as IMMSessionManager3;

            if (sm == null)
            {
                return(null);
            }

            if (sm.CurrentOpenSession == null)
            {
                return(null);
            }

            return(action(sm.CurrentOpenSession.get_ID(), source));
        }
Esempio n. 2
0
        /// <summary>
        ///     Returns the <see cref="Session" /> implementation of the current open session.
        /// </summary>
        /// <param name="source">The process framework application.</param>
        /// <returns>
        ///     Returns a <see cref="Session" /> representing the session; otherwise <c>null</c>.
        /// </returns>
        public static Session GetSession(this IMMPxApplication source)
        {
            if (source == null)
            {
                return(null);
            }

            var sm = source.GetSessionManager() as IMMSessionManager3;

            if (sm == null)
            {
                return(null);
            }

            if (sm.CurrentOpenSession == null)
            {
                return(null);
            }

            return(new Session(source, sm.CurrentOpenSession));
        }