public WeChatClient( WeChatSettings settings, IStorage storage, ILogger logger = null) { _settings = settings; _attachmentStorage = new WeChatAttachmentStorage(storage); _tokenStorage = new AccessTokenStorage(storage); _logger = logger ?? NullLogger.Instance; _attachmentHash = new AttachmentHash(); _semaphore = new SemaphoreSlim(1); }
public WeChatHttpAdapter( WeChatSettings settings, IStorage storage, IBackgroundTaskQueue taskQueue = null, ILogger logger = null) { _settings = settings; _wechatClient = new WeChatClient(settings, storage, logger); _wechatMessageMapper = new WeChatMessageMapper(_wechatClient, settings.UploadTemporaryMedia, logger); _logger = logger ?? NullLogger.Instance; _taskQueue = taskQueue; }
/// <summary> /// Initializes a new instance of the <see cref="MessageCryptography"/> class. /// </summary> /// <param name="secretInfo">The secret info provide by WeChat.</param> /// <param name="settings">The WeChat settings.</param> public MessageCryptography(SecretInfo secretInfo, WeChatSettings settings) { if (string.IsNullOrEmpty(settings.EncodingAesKey) || settings.EncodingAesKey.Length != 43) { throw new ArgumentException("Invalid EncodingAESKey.", nameof(secretInfo)); } _token = settings.Token; _appId = settings.AppId; _encodingAesKey = settings.EncodingAesKey; _msgSignature = secretInfo.MessageSignature; _timestamp = secretInfo.Timestamp; _nonce = secretInfo.Nonce; }