public Task PublishAsync(IMobileServiceEvent mobileServiceEvent) { if (mobileServiceEvent == null) { throw new ArgumentNullException("mobileServiceEvent"); } return(Task.Run(() => { TypeInfo messageType = mobileServiceEvent.GetType().GetTypeInfo(); this.subscriptionLock.EnterReadLock(); IList <ISubscription> subscriptionMatches = null; try { subscriptionMatches = this.subscriptions.Where(s => s.TargetMessageType.GetTypeInfo() .IsAssignableFrom(messageType)).ToList(); } finally { this.subscriptionLock.ExitReadLock(); } foreach (var subscription in subscriptionMatches) { subscription.OnNext(mobileServiceEvent); } })); }
public Task PublishAsync(IMobileServiceEvent mobileServiceEvent) { Arguments.IsNotNull(mobileServiceEvent, nameof(mobileServiceEvent)); return(Task.Run(() => { TypeInfo messageType = mobileServiceEvent.GetType().GetTypeInfo(); subscriptionLock.EnterReadLock(); IList <ISubscription> subscriptionMatches = null; try { subscriptionMatches = subscriptions.Where(s => s.TargetMessageType.GetTypeInfo().IsAssignableFrom(messageType)).ToList(); } finally { subscriptionLock.ExitReadLock(); } foreach (var subscription in subscriptionMatches) { subscription.OnNext(mobileServiceEvent); } })); }