Esempio n. 1
0
        public OnElementLoadedEvent(
            [Import(AllowDefault = true)] IPatternManager patternManager,
            [Import(AllowDefault = true)] IInstanceBase currentElement)
        {
            this.currentElement = currentElement;
            this.patternManager = patternManager;

            this.sourceEvent = WeakObservable.FromEvent <EventArgs>(
                handler => this.ElementLoaded += handler,
                handler => this.ElementLoaded -= handler);

            if (patternManager != null)
            {
                this.patternManager.IsOpenChanged += (sender, args) => this.OnOpenChanged();

                if (this.patternManager.IsOpen)
                {
                    this.storeEvent = WeakObservable.FromEvent <ValueEventArgs <IInstanceBase> >(
                        handler => this.patternManager.Store.ElementLoaded += handler,
                        handler => this.patternManager.Store.ElementLoaded -= handler);

                    this.storeEventSubscription = this.storeEvent.Subscribe(this.OnStoreElementLoaded);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OnSyncEvent"/> class.
 /// </summary>
 static OnSyncEvent()
 {
     if (sourceEvent == null)
     {
         sourceEvent = WeakObservable.FromEvent <EventArgs>(
             handler => SyncEvent += handler,
             handler => SyncEvent -= handler);
     }
 }
Esempio n. 3
0
        public EventPublisher(INotifyPropertyChanged eventSource)
        {
            //// this.eventSource = eventSource;

            this.observable = WeakObservable.FromEvent <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                handler => new PropertyChangedEventHandler(handler.Invoke),
                handler => eventSource.PropertyChanged += handler,
                handler => eventSource.PropertyChanged -= handler);
        }
Esempio n. 4
0
        public OnBuildFinishedEvent([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.dte = serviceProvider.GetService <EnvDTE.DTE>();
            this.dte.Events.BuildEvents.OnBuildDone += this.OnDteBuildDone;

            this.sourceEvent = WeakObservable.FromEvent <EventArgs>(
                handler => this.BuildFinished += handler,
                handler => this.BuildFinished -= handler);
        }
        public OnSolutionBuilderDragLeave([Import] SolutionBuilderView solutionBuilder)
        {
            Guard.NotNull(() => solutionBuilder, solutionBuilder);

            this.solutionBuilder = solutionBuilder;

            this.sourceEvent = WeakObservable.FromEvent <DragEventHandler, DragEventArgs>(
                handler => new DragEventHandler(handler),
                handler => this.solutionBuilder.ElementDragLeave += handler,
                handler => this.solutionBuilder.ElementDragLeave -= handler);
        }
        public OnElementPropertyChangedEvent([Import(AllowDefault = true)] IProductElement productElement)
        {
            // We get null when the event is being validated as it's constructed from the global
            // composition container to retrieve the event type.
            // See EventSettingsValidations constructor.
            if (productElement != null)
            {
                this.productElement = productElement;
                this.productElement.PropertyChanged += OnPropertyChanged;
            }

            this.localSourceEvent = WeakObservable.FromEvent <PropertyChangedEventArgs>(
                handler => this.ElementPropertyChanged += handler,
                handler => this.ElementPropertyChanged -= handler);
        }
Esempio n. 7
0
        private void OnOpenChanged()
        {
            if (this.storeEventSubscription != null)
            {
                this.storeEventSubscription.Dispose();
            }

            if (this.patternManager.IsOpen)
            {
                this.storeEvent = WeakObservable.FromEvent <ValueEventArgs <IInstanceBase> >(
                    handler => this.patternManager.Store.ElementInstantiated += handler,
                    handler => this.patternManager.Store.ElementInstantiated -= handler);

                this.storeEventSubscription = this.storeEvent.Subscribe(this.OnStoreElementInstantiated);
            }
        }
Esempio n. 8
0
        private void OnOpenChanged()
        {
            if (this.storeEventSubscription != null)
            {
                this.storeEventSubscription.Dispose();
            }

            if (this.patternManager.IsOpen)
            {
                this.storeEvent = WeakObservable.FromEvent <ValueEventArgs <IProductState> >(
                    handler => this.patternManager.StoreSaved += handler,
                    handler => this.patternManager.StoreSaved -= handler);

                this.storeEventSubscription = this.storeEvent.Subscribe(this.OnStoreProductStoreSaved);
            }
        }
Esempio n. 9
0
        public OnProductStoreSavedEvent(IPatternManager patternManager)
        {
            Guard.NotNull(() => patternManager, patternManager);

            this.patternManager = patternManager;
            this.patternManager.IsOpenChanged += (sender, args) => this.OnOpenChanged();

            this.sourceEvent = WeakObservable.FromEvent <EventArgs>(
                handler => this.ProductStoreSaved += handler,
                handler => this.ProductStoreSaved -= handler);

            if (this.patternManager.IsOpen)
            {
                this.storeEvent = WeakObservable.FromEvent <ValueEventArgs <IProductState> >(
                    handler => this.patternManager.StoreSaved += handler,
                    handler => this.patternManager.StoreSaved -= handler);

                this.storeEventSubscription = this.storeEvent.Subscribe(this.OnStoreProductStoreSaved);
            }
        }
Esempio n. 10
0
 public void WhenNullConversionHandler_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           WeakObservable.FromEvent <EventHandler, EventArgs>(null, handler => { }, handler => { }));
 }
Esempio n. 11
0
 public void WhenNullRemoveHandler_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           WeakObservable.FromEvent <EventArgs>(handler => { }, null));
 }