private static PowwaReturnValue <T> HttpEndpointWrapper <T>(string sessionKey, Func <PowwaSession, T> function) { PowwaReturnValue <T> powwaReturnValue; PowwaSession session = null; try { try { session = PowwaSessionManager.Instance.GetSession(SessionHelper.GetSessionId()); } catch (ArgumentException argumentException) { powwaReturnValue = PowwaReturnValue <T> .CreateError(PowwaException.CreateInvalidSessionException()); return(powwaReturnValue); } if (string.Compare(sessionKey, session.SessionKey, StringComparison.OrdinalIgnoreCase) == 0) { if (string.Compare(SessionHelper.GetAuthenticatedUser(), session.UserName, StringComparison.OrdinalIgnoreCase) == 0) { powwaReturnValue = PowwaReturnValue <T> .CreateSuccess(function(session)); } else { PowwaEvents.PowwaEVENT_INVALID_SESSION_USER(session.Name, SessionHelper.GetAuthenticatedUser(), session.UserName, SessionHelper.GetSourceIPAddressRemoteAddr(), SessionHelper.GetSourceIPAddressHttpXForwardedFor()); powwaReturnValue = PowwaReturnValue <T> .CreateError(PowwaException.CreateInvalidSessionException()); } } else { PowwaEvents.PowwaEVENT_INVALID_SESSION_KEY(session.Name, SessionHelper.GetAuthenticatedUser(), SessionHelper.GetSourceIPAddressRemoteAddr(), SessionHelper.GetSourceIPAddressHttpXForwardedFor()); powwaReturnValue = PowwaReturnValue <T> .CreateError(PowwaException.CreateInvalidSessionException()); } } catch (PowwaException powwaException1) { PowwaException powwaException = powwaException1; powwaReturnValue = PowwaReturnValue <T> .CreateError(powwaException); } catch (Exception exception1) { Exception exception = exception1; PowwaEvents.PowwaEVENT_GENERIC_FAILURE(session.Name, exception.Message); powwaReturnValue = PowwaReturnValue <T> .CreateGenericError(exception); } return(powwaReturnValue); }