Beispiel #1
0
        public virtual StandardResponse <bool> Stamp(MessageContext messageContext
                                                     , bool includeContext = false
                                                     , bool includeScopes  = false
                                                     )
        {
            if (PassportStorageService == null)
            {
                return(false.GenerateStandardResponse());
            }

            try
            {
                var contexts = new PassportsContext();
                var scopes   = new List <string>();

                if (includeContext)
                {
                    foreach (var context in Contexts)
                    {
                        contexts[context.Key] = context.Value;
                    }

                    var extendedContexts = ExtendedContexts();
                    if (extendedContexts != null)
                    {
                        foreach (var extendedContext in extendedContexts)
                        {
                            contexts[extendedContext.Key] = extendedContext.Value;
                        }
                    }
                }

                if (includeScopes)
                {
                    scopes.AddRange(Scopes.Serialize());
                }

                SendInBackground(messageContext, contexts.ToArray(), scopes.ToArray());
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("Failed SendInBackground: {0}", e.Message);
                return(false.GenerateStandardResponse());
            }

            return(true.GenerateStandardResponse());
        }
        public virtual StandardResponse<bool> Stamp(MessageContext messageContext
                                                    , bool includeContext = false
                                                    , bool includeScopes = false
            )
        {
            if (PassportStorageService == null)
                return false.GenerateStandardResponse();

            try
            {
                var contexts = new PassportsContext();
                var scopes = new List<string>();

                if (includeContext)
                {
                    foreach (var context in Contexts)
                    {
                        contexts[context.Key] = context.Value;
                    }

                    var extendedContexts = ExtendedContexts();
                    if (extendedContexts != null)
                    {
                        foreach (var extendedContext in extendedContexts)
                        {
                            contexts[extendedContext.Key] = extendedContext.Value;
                        }
                    }
                }

                if (includeScopes)
                {
                    scopes.AddRange(Scopes.Serialize());
                }

                SendInBackground(messageContext, contexts.ToArray(), scopes.ToArray());
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("Failed SendInBackground: {0}", e.Message);
                return false.GenerateStandardResponse();
            }

            return true.GenerateStandardResponse();
        }
Beispiel #3
0
        public StandardResponse <bool> StampException(MessageContext messageContext, Exception e)
        {
            if (PassportStorageService == null || e == null)
            {
                return(false.GenerateStandardResponse());
            }

            try
            {
                var contexts = new PassportsContext();
                var scopes   = new List <string>();

                foreach (var context in Contexts)
                {
                    contexts[context.Key] = context.Value;
                }

                var extendedContexts = ExtendedContexts();
                if (extendedContexts != null)
                {
                    foreach (var extendedContext in extendedContexts)
                    {
                        contexts[extendedContext.Key] = extendedContext.Value;
                    }
                }

                contexts[Constants.Contexts.Exception] = new ExceptionContext(e);

                scopes.AddRange(Scopes.Serialize());

                SendInBackground(messageContext, contexts.ToArray(), scopes.ToArray());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Failed SendInBackground: {0}", ex.Message);
                return(false.GenerateStandardResponse());
            }

            return(true.GenerateStandardResponse());
        }
        public StandardResponse<bool> StampException(MessageContext messageContext, Exception e)
        {
            if (PassportStorageService == null || e == null)
                return false.GenerateStandardResponse();

            try
            {
                var contexts = new PassportsContext();
                var scopes = new List<string>();

                foreach (var context in Contexts)
                {
                    contexts[context.Key] = context.Value;
                }
                
                var extendedContexts = ExtendedContexts();
                if (extendedContexts != null)
                {
                    foreach (var extendedContext in extendedContexts)
                    {
                        contexts[extendedContext.Key] = extendedContext.Value;
                    }
                }

                contexts[Constants.Contexts.Exception] = new ExceptionContext(e);

                scopes.AddRange(Scopes.Serialize());

                SendInBackground(messageContext, contexts.ToArray(), scopes.ToArray());
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Failed SendInBackground: {0}", ex.Message);
                return false.GenerateStandardResponse();
            }

            return true.GenerateStandardResponse();
        }