コード例 #1
0
        public Task DeleteAsync <T>(string traderId) where T : TraderSettingsBase, new()
        {
            var partitionKey = ClientSettingsEntity.GeneratePartitionKey(traderId);
            var defaultValue = TraderSettingsBase.CreateDefault <T>();
            var rowKey       = ClientSettingsEntity.GenerateRowKey(defaultValue);

            return(_tableStorage.DeleteAsync(partitionKey, rowKey));
        }
コード例 #2
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>());
        }
コード例 #3
0
        public static ClientSettingsEntity Create(string traderId, TraderSettingsBase settings)
        {
            var result = new ClientSettingsEntity
            {
                PartitionKey = GeneratePartitionKey(traderId),
                RowKey       = GenerateRowKey(settings),
            };

            result.SetSettings(settings);
            return(result);
        }
コード例 #4
0
        public Task SetSettings <T>(string traderId, T settings) where T : TraderSettingsBase, new()
        {
            var newEntity = ClientSettingsEntity.Create(traderId, settings);

            return(_tableStorage.InsertOrReplaceAsync(newEntity));
        }