Esempio n. 1
0
        public async Task <TryGetUniqueValueKeyResult <TAggregateIdentity> > TryGetUniqueValueKey <TAggregateIdentity>(string valueGroup, string value, bool ignoreCase = true)
            where TAggregateIdentity : class, IAggregateIdentity
        {
            var response = await table.ExecuteAsync(TableOperation.Retrieve <UniqueEntry>(valueGroup, value));

            var entry = response.Result as UniqueEntry;

            if (entry == null)
            {
                return(TryGetUniqueValueKeyResult <TAggregateIdentity> .Empty);
            }
            return(TryGetUniqueValueKeyResult <TAggregateIdentity> .WithResult(Newtonsoft.Json.JsonConvert.DeserializeObject <TAggregateIdentity>(entry.Id)));
        }
Esempio n. 2
0
        public Task <TryGetUniqueValueKeyResult <TAggregateIdentity> > TryGetUniqueValueKey <TAggregateIdentity>(string valueGroup, string value, bool ignoreCase = true)
            where TAggregateIdentity : class, IAggregateIdentity
        {
            if (string.IsNullOrEmpty(valueGroup))
            {
                throw new ArgumentNullException("valueGroup");
            }
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException("value");
            }

            ConcurrentDictionary <string, IAggregateIdentity> groupValues;
            IAggregateIdentity key;

            if (groups.TryGetValue(valueGroup, out groupValues) && groupValues.TryGetValue(value, out key))
            {
                return(Task.FromResult(TryGetUniqueValueKeyResult <TAggregateIdentity> .WithResult((TAggregateIdentity)key)));
            }
            return(Task.FromResult(TryGetUniqueValueKeyResult <TAggregateIdentity> .Empty));
        }