Exemple #1
0
        public void Send(MessageContext messageContext)
        {
            var snapshot = new Dictionary <string, object>();

            if (CurrentContexts.IsValueCreated)
            {
                if (CurrentContexts.Value.Any())
                {
                    foreach (var context in CurrentContexts.Value)
                    {
                        snapshot[context.Key] = JObject.Parse(JsonConvert.SerializeObject(context.Value));
                    }
                }
            }

            if (CurrentScopes.IsValueCreated)
            {
                if (CurrentScopes.Value.Any())
                {
                    var scopeEntries = new JArray(CurrentScopes.Value.Select(JObject.Parse).ToList());
                    snapshot[Constants.Passports.KeyScopes] = scopeEntries.OrderBy(x => (DateTimeOffset)x[Constants.PassportScope.Entry.Timestamp])
                                                              .ToList();
                }
            }

            PassportStorageService.Store(messageContext, snapshot);
        }