예제 #1
0
        public async Task <T> GetSettings <T>(string traderId) where T : TraderSettingsBase, new()
        {
            var partitionKey = ClientSettingsEntity.GeneratePartitionKey(traderId);
            var defaultValue = TraderSettingsBase.CreateDefault <T>();
            var rowKey       = ClientSettingsEntity.GenerateRowKey(defaultValue);
            var entity       = await _tableStorage.GetDataAsync(partitionKey, rowKey);

            return(entity == null ? defaultValue : entity.GetSettings <T>());
        }
예제 #2
0
        public static ClientSettingsEntity Create(string traderId, TraderSettingsBase settings)
        {
            var result = new ClientSettingsEntity
            {
                PartitionKey = GeneratePartitionKey(traderId),
                RowKey       = GenerateRowKey(settings),
            };

            result.SetSettings(settings);
            return(result);
        }
예제 #3
0
        public Task SetSettings <T>(string traderId, T settings) where T : TraderSettingsBase, new()
        {
            var newEntity = ClientSettingsEntity.Create(traderId, settings);

            return(_tableStorage.InsertOrReplaceAsync(newEntity));
        }