public IDisposable Subscribe(IConfigurationSubscriber <TConfig> subscriber, out TConfig currentConfig)
        {
            if (subscriber == null)
            {
                throw new ArgumentNullException("subscriber");
            }
            var subscription = new Subscription(this, subscriber);

            subscriptions.Add(subscription);
            currentConfig = this.currentConfig;
            return(subscription);
        }
Beispiel #2
0
        internal ConfigurationServicePSharpProxy(MachineId callerMachineId, MachineId hostMachineId,
                                                 IConfigurationService <TConfig> original)
        {
            TConfig initialConfig;

            originalProxy = PSharpRealProxy.MakeTransparentProxy(callerMachineId, hostMachineId, original,
                                                                 null, () => new GenericDispatchableEvent());

            IConfigurationSubscriber <TConfig> subscriberReverseProxy =
                PSharpRealProxy.MakeTransparentProxy(hostMachineId, callerMachineId,
                                                     (IConfigurationSubscriber <TConfig>) new Subscriber(this), null,
                                                     () => new GenericDispatchableEvent());

            // XXX Implement IDisposable.  Would need to proxy the dispose as well.
            original.Subscribe(subscriberReverseProxy, out initialConfig);

            mirror = new InMemoryConfigurationService <TConfig>(initialConfig);
        }
        public IDisposable Subscribe(IConfigurationSubscriber <TConfig> subscriber, out TConfig currentConfig)
        {
            int subscriptionNum = subscriptionCount++;
            var subscriberProxy = new SubscriberLoggingProxy(subscriber, string.Format("{0} subscriber {1}", proxyName, subscriptionNum));

            CallLogging.LogStart(proxyName, nameof(Subscribe), subscriberProxy);
            // Some mess because of "out" parameter.  Does the convenience of
            // "out" parameters in the common case merit the mess here?
            var t = LogOutcome(() => {
                TConfig currentConfig1;
                var subscriptionProxy1 = new SubscriptionLoggingProxy(
                    original.Subscribe(subscriberProxy, out currentConfig1),
                    string.Format("{0} subscription {1}", proxyName, subscriptionNum));
                return(Tuple.Create(currentConfig1, subscriptionProxy1));
            }, (outcome) => CallLogging.LogEnd(proxyName, nameof(Subscribe), outcome, subscriberProxy));

            currentConfig = t.Item1;
            return(t.Item2);
        }
Beispiel #4
0
 public IDisposable Subscribe(IConfigurationSubscriber <TConfig> subscriber, out TConfig currentConfig)
 {
     return(mirror.Subscribe(subscriber, out currentConfig));
 }
 internal Subscription(InMemoryConfigurationService <TConfig> service, IConfigurationSubscriber <TConfig> subscriber)
 {
     this.service    = service;
     this.subscriber = subscriber;
 }
 internal SubscriberLoggingProxy(IConfigurationSubscriber <TConfig> original, string proxyName)
 {
     this.original  = original;
     this.proxyName = proxyName;
 }