Пример #1
0
        public FileChannelClient(string channel, string client = null, string directory = null, IFileChannelFormatter formatter = null)
        {
            if (string.IsNullOrEmpty(channel))
            {
                throw new ArgumentNullException(nameof(channel));
            }

            if (string.IsNullOrEmpty(client))
            {
                client = Guid.NewGuid().ToString("N");
            }

            if (string.IsNullOrEmpty(directory))
            {
                directory = AppDomain.CurrentDomain.BaseDirectory;
            }

            if (formatter == null)
            {
                formatter = JsonFileChannelFormatter.Instance;
            }

            InvokeTimeout = DefaultInvokeTimeout;

            _client = client;
            _dispatcher = new FileChannelClientDispatcher(directory, client, channel, formatter, OnReceiveReplyMessage);
            _requests = new ConcurrentDictionary<string, TaskCompletionSource<object>>();
        }
Пример #2
0
        public FileChannelClient(string channel, string client = null, string directory = null, IFileChannelFormatter formatter = null)
        {
            if (string.IsNullOrEmpty(channel))
            {
                throw new ArgumentNullException(nameof(channel));
            }

            if (string.IsNullOrEmpty(client))
            {
                client = Guid.NewGuid().ToString("N");
            }

            if (string.IsNullOrEmpty(directory))
            {
                directory = AppDomain.CurrentDomain.BaseDirectory;
            }

            if (formatter == null)
            {
                formatter = JsonFileChannelFormatter.Instance;
            }

            InvokeTimeout = DefaultInvokeTimeout;

            _client     = client;
            _dispatcher = new FileChannelClientDispatcher(directory, client, channel, formatter, OnReceiveReplyMessage);
            _requests   = new ConcurrentDictionary <string, TaskCompletionSource <object> >();
        }