public async Task <ConditionalValue <Dictionary <TKey, TValue> > > TryCopyToDictionary <TKey, TValue>(string sourceKey, IReliableStateManager stateManager) where TKey : IComparable <TKey>, IEquatable <TKey> { var conditionalValue = await reliableStateManagerHelper.TryGetAsync <IReliableDictionary <TKey, TValue> >(stateManager, sourceKey); if (!conditionalValue.HasValue) { return(new ConditionalValue <Dictionary <TKey, TValue> >(false, null)); } IReliableDictionary <TKey, TValue> source = conditionalValue.Value; return(await TryCopyToDictionary <TKey, TValue>(source, stateManager)); }
public async Task InitializeReliableDictionary(string reliableDictioanryName = "") { if (string.IsNullOrEmpty(reliableDictioanryName)) { reliableDictioanryName = this.reliableDictionaryName; } using (ITransaction tx = this.stateManager.CreateTransaction()) { var result = await reliableStateManagerHelper.TryGetAsync <IReliableDictionary <TKey, TValue> >(this.stateManager, reliableDictioanryName); if (result.HasValue) { this.reliableDictionary = result.Value; await tx.CommitAsync(); } else { string message = $"ReliableCollection Key: {reliableDictioanryName}, Type: {typeof(IReliableDictionary<TKey, TValue>)} was not initialized."; throw new Exception(message); } } }