Пример #1
0
 public EventListenerRequest(IEventContract contract, Cache cache)
     : base(contract.Reference, HttpMethod.Get)
 {
     this.contract = contract;
     this.cache = cache;
     cts = new CancellationTokenSource();
 }
Пример #2
0
 public EventListenerRequest(IEventContract contract, Cache cache)
     : base(contract.Reference, HttpMethod.Get)
 {
     this.contract = contract;
     this.cache    = cache;
     cts           = new CancellationTokenSource();
 }
Пример #3
0
        public void AddContract(IEventContract contract)
        {
            if (_contracts.Any(c => c.Name == contract.Name))
            {
                throw new EventNameInUseException(contract.Name);
            }

            _contracts.Add(contract);
        }
Пример #4
0
 public bool Equals(IEventContract other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Reference.Equals(other.Reference));
 }
Пример #5
0
 public bool Equals(IEventContract other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     return Reference.Equals(other.Reference);
 }
Пример #6
0
        public void RemoveEventListener(IEventContract contract)
        {
            CheckDisposed();

            ArgUtils.CheckForNull(contract, nameof(contract));

            EventListenerRequest eventListenerRequest;
            if (!eventListenerRequests.TryGetValue(contract, out eventListenerRequest))
                return;

            eventListenerRequests.Remove(contract);

            eventListenerRequest.Stop();
        }
Пример #7
0
        public void RemoveEventListener(IEventContract contract)
        {
            CheckDisposed();

            ArgUtils.CheckForNull(contract, nameof(contract));

            EventListenerRequest eventListenerRequest;

            if (!eventListenerRequests.TryGetValue(contract, out eventListenerRequest))
            {
                return;
            }

            eventListenerRequests.Remove(contract);

            eventListenerRequest.Stop();
        }
Пример #8
0
        public async void AddEventListener(IEventContract contract)
        {
            CheckDisposed();

            ArgUtils.CheckForNull(contract, nameof(contract));

            if (eventListenerRequests.ContainsKey(contract))
                return;

            var eventListenerRequest = new EventListenerRequest(contract, new Cache());
            eventListenerRequests.Add(contract, eventListenerRequest);

            HttpRequestMessage requestMessage = eventListenerRequest.CreateRequestMessage(Context);
            HttpResponseMessage httpResponseMessage =
                await SendRequestMessage(requestMessage, HttpCompletionOption.ResponseHeadersRead);
            eventListenerRequest.CreateResult(httpResponseMessage, Context);
        }
Пример #9
0
        public async void AddEventListener(IEventContract contract)
        {
            CheckDisposed();

            ArgUtils.CheckForNull(contract, nameof(contract));

            if (eventListenerRequests.ContainsKey(contract))
            {
                return;
            }

            var eventListenerRequest = new EventListenerRequest(contract, new Cache());

            eventListenerRequests.Add(contract, eventListenerRequest);

            HttpRequestMessage  requestMessage      = eventListenerRequest.CreateRequestMessage(Context);
            HttpResponseMessage httpResponseMessage =
                await SendRequestMessage(requestMessage, HttpCompletionOption.ResponseHeadersRead);

            eventListenerRequest.CreateResult(httpResponseMessage, Context);
        }