<commit_before>﻿using System;
using System.Linq;
using Binance.Api;
using Binance.WebSocket.Events;
using Microsoft.Extensions.Logging;

namespace Binance.WebSocket.UserData
{
    public class SingleUserDataWebSocketClient : UserDataWebSocketClient, ISingleUserDataWebSocketClient
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public SingleUserDataWebSocketClient()
            : this (new BinanceApi(), new WebSocketStreamProvider())
        { }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="api"></param>
        /// <param name="streamProvider"></param>
        /// <param name="logger"></param>
        public SingleUserDataWebSocketClient(IBinanceApi api, IWebSocketStreamProvider streamProvider, ILogger<SingleUserDataWebSocketClient> logger = null)
            : base(api, streamProvider.CreateStream(), logger)
        { }

        public override void Subscribe(string listenKey, IBinanceApiUser user, Action<UserDataEventArgs> callback)
        {
            Throw.IfNull(user, nameof(user));

            if (ListenKeys.Count > 0 && ListenKeys.Single().Value != user)
                throw new InvalidOperationException($"{nameof(SingleUserDataWebSocketClient)}: Can only subscribe to a single a user.");

            base.Subscribe(listenKey, user, callback);
        }
    }
}<commit_msg>Add comment<commit_after>﻿using System;
using System.Linq;
using Binance.Api;
using Binance.WebSocket.Events;
using Microsoft.Extensions.Logging;

namespace Binance.WebSocket.UserData
{
    public class SingleUserDataWebSocketClient : UserDataWebSocketClient, ISingleUserDataWebSocketClient
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public SingleUserDataWebSocketClient()
            : this (new BinanceApi(), new WebSocketStreamProvider())
        { }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="api"></param>
        /// <param name="streamProvider"></param>
        /// <param name="logger"></param>
        public SingleUserDataWebSocketClient(IBinanceApi api, IWebSocketStreamProvider streamProvider, ILogger<SingleUserDataWebSocketClient> logger = null)
            : base(api, streamProvider.CreateStream(), logger)
        { }

        public override void Subscribe(string listenKey, IBinanceApiUser user, Action<UserDataEventArgs> callback)
        {
            Throw.IfNull(user, nameof(user));

            // Ensure only one user is subscribed.
            if (ListenKeys.Count > 0 && ListenKeys.Single().Value != user)
                throw new InvalidOperationException($"{nameof(SingleUserDataWebSocketClient)}: Can only subscribe to a single a user.");

            base.Subscribe(listenKey, user, callback);
        }
    }
}
{'fraction_non_alphanumeric': 0.11425539441103644, 'fraction_numerical': 0.0007074637424831977, 'mean_word_length': 2.6822916666666665, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '677587', 'n_tokens_mistral': 741, 'n_tokens_neox': 728, 'n_words': 161}