Esempio n. 1
0
        private static void _ExportsChanged(object sender, ExportsChangeEventArgs args)
        {
            try
            {
                if (args.AddedExports != null)
                {
                    _ParseExports("** Added Export: ", args.AddedExports);
                }

                if (args.RemovedExports != null)
                {
                    _ParseExports("** Removed Export: ", args.RemovedExports);
                }

                if (args.ChangedContractNames != null)
                {
                    var first = true;
                    foreach (var contract in args.ChangedContractNames)
                    {
                        if (first)
                        {
                            Console.WriteLine("=== Contracts Changed ===");
                            first = false;
                        }
                        Console.WriteLine(" ==>{0}", contract);
                    }
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine("### MEF Debugger Error: {0}", ex.Message);
            }
        }
        void SourceExportsChanging(object sender, ExportsChangeEventArgs e)
        {
            if (SentByThis(e))
                return;

            OnExportsChanging(ProjectChangeEvent(e));
        }
        ExportsChangeEventArgs ProjectChangeEvent(ExportsChangeEventArgs e)
        {
            var satisfiedImports = _importDefinitionCache.Values;

            return new TaggedExportsChangedEventArgs(
                this,
                ProjectProductExportsIntoSatsifedCreatorExports(satisfiedImports, e.AddedExports),
                ProjectProductExportsIntoSatsifedCreatorExports(satisfiedImports, e.RemovedExports),
                e.AtomicComposition);
        }
Esempio n. 4
0
 private void ExportsChangeing(object sender, ExportsChangeEventArgs exportsChangeEventArgs)
 {
     VisualServieMetadatas =
         new ObservableCollection<IVisualServiceMetadata>(
             VisualMainWindow.ApplicationProxy.VisualModuleManager.GetVisualServicesMetadata()
                             .OrderBy(s => s.Descriptor));
 }
Esempio n. 5
0
 private void OnExportChangingInternal(object sender, ExportsChangeEventArgs e)
 {
     this.OnExportsChanging(e);
 }
        /// <summary>
        /// Fired when exports are changing.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void SourceExportsChanging(object sender, ExportsChangeEventArgs e)
        {
            if (!SelfSent(e))
                return;

            OnExportsChanging(ProjectChangeEvent(e));
        }
        /// <summary>
        /// Creates a new instance of <see cref="TaggedExportsChangeEventArgs" /> for the given event arguments.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        /// <returns>A new instance of <see cref="TaggedExportsChangeEventArgs" /> for the given event arguments.</returns>
        private TaggedExportsChangeEventArgs ProjectChangeEvent(ExportsChangeEventArgs e)
        {
            var satisfiedImports = _definitionCache.Values;

            return new TaggedExportsChangeEventArgs(
                this,
                ProjectExportsDefinitions(satisfiedImports, e.AddedExports),
                ProjectExportsDefinitions(satisfiedImports, e.RemovedExports),
                e.AtomicComposition);
        }
 /// <summary>
 ///     Raises the <see cref="ExportsChanging"/> event.
 /// </summary>
 /// <param name="e">
 ///     An <see cref="ExportsChangeEventArgs"/> containing the data for the event.
 /// </param>
 protected virtual void OnExportsChanging(ExportsChangeEventArgs e)
 {
     EventHandler<ExportsChangeEventArgs> changingEvent = this.ExportsChanging;
     if (changingEvent != null)
     {
         CompositionResult result = CompositionServices.TryFire(changingEvent, this, e);
         result.ThrowOnErrors(e.AtomicComposition);
     }
 }
Esempio n. 9
0
 private void OnExportChangingInternal(object?sender, ExportsChangeEventArgs e)
 {
     OnExportsChanging(e);
 }
Esempio n. 10
0
 internal void OnExportsChangedInternal(object?sender, ExportsChangeEventArgs e)
 {
     OnExportsChanged(e);
 }
 private void OnExportChangedInternal(object sender, ExportsChangeEventArgs e)
 {
     this.OnExportsChanged(e);
 }
Esempio n. 12
0
 private void Action(object sender, ExportsChangeEventArgs exportsChangeEventArgs)
 {
     VisualServiceMetadatas = new ObservableCollection<MetadataEx>(Module.Context.ServicePool.GetMetadatas<IVisualServiceMetadata>().Select(s => new MetadataEx(s)));
     ServiceMetadatas = new ObservableCollection<MetadataEx>(Module.Context.ServicePool.GetAllMetadata().Select(s => new MetadataEx(s)).Except(VisualServiceMetadatas));
 }
 private void Recompose(object sender, ExportsChangeEventArgs e)
 {
     Recompose();
 }
 protected virtual new void OnExportsChanging(ExportsChangeEventArgs e)
 {
 }
 protected virtual new void OnExportsChanging(ExportsChangeEventArgs e)
 {
     Contract.Requires(e != null);
 }
 bool SentByThis(ExportsChangeEventArgs e)
 {
     return e is TaggedExportsChangedEventArgs &&
         ((TaggedExportsChangedEventArgs)e).Sender == this;
 }
Esempio n. 17
0
        private void ContainerExportsChanged(object sender, ExportsChangeEventArgs e) {
            // figure out the new extensions...
            var extensions = _container.GetExports<IAnalysisExtension, IDictionary<string, object>>();
            HashSet<IAnalysisExtension> newExtensions = new HashSet<IAnalysisExtension>();
            lock (_registeredExtensions) {
                foreach (var extension in extensions) {

                    if (!_registeredExtensions.Contains(extension.Value)) {
                        
                        newExtensions.Add(extension.Value);
                        if (extension.Metadata.ContainsKey("Name") && extension.Metadata["Name"] is string) {
                            _extensionsByName[(string)extension.Metadata["Name"]] = extension.Value;
                        } else {
                            Console.Error.WriteLine("Extension {0} has no name, will not respond to commands", extension.Value);
                        }
                    }
                }

                _registeredExtensions.UnionWith(newExtensions);
            }

            // inform them of the analyzer...
            foreach (var extension in newExtensions) {
                extension.Register(_pyAnalyzer);
            }
        }
 private void OnExportsChangingInternal(object?sender, ExportsChangeEventArgs e)
 {
     UpdateRejections(e.AddedExports.Concat(e.RemovedExports), e.AtomicComposition);
 }
 void provider_ExportsChanged(object sender, ExportsChangeEventArgs args)
 {
     Contract.Requires<ArgumentNullException>(sender != null);
     Contract.Requires<ArgumentNullException>(args != null);
     OnExportsChanged(args);
 }
 internal void OnExportsChangingInternal(object sender, ExportsChangeEventArgs e)
 {
     OnExportsChanging(e);
 }
 /// <summary>
 /// Determines if the specified event arguments were sent by this instance.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 /// <returns>True if the specified event arguments were sent by this instance, otherwise false.</returns>
 private bool SelfSent(ExportsChangeEventArgs e)
 {
     return (e is TaggedExportsChangeEventArgs
             && ((TaggedExportsChangeEventArgs)e).Sender == this);
 }
Esempio n. 22
0
        private void OnExportsChanging(object sender, ExportsChangeEventArgs e)
        {
            CompositionResult result = CompositionResult.SucceededResult;

            // Prepare for the recomposition effort by minimizing the amount of work we'll have to do later
            AtomicComposition atomicComposition = e.AtomicComposition;

            IEnumerable<PartManager> affectedParts = this._recompositionManager.GetAffectedParts(e.ChangedContractNames);

            // When in a atomicComposition account for everything that isn't yet reflected in the
            // index
            if (atomicComposition != null)
            {
                EngineContext engineContext;
                if (atomicComposition.TryGetValue(this, out engineContext))
                {
                    // always added the new part managers to see if they will also be 
                    // affected by these changes
                    affectedParts = affectedParts.ConcatAllowingNull(engineContext.GetAddedPartManagers())
                        .Except(engineContext.GetRemovedPartManagers());
                }
            }

            var changedExports = e.AddedExports.ConcatAllowingNull(e.RemovedExports);

            foreach (var partManager in affectedParts)
            {
                result = result.MergeResult(this.TryRecomposeImports(partManager, changedExports, atomicComposition));
            }

            result.ThrowOnErrors(atomicComposition);
        }
Esempio n. 23
0
        private void ExportsChanged(object sender, ExportsChangeEventArgs args)
        {
            try
            {
                if (args.AddedExports != null)
                {
                    ParseExports(MsgAddExport, args.AddedExports);
                }

                if (args.RemovedExports != null)
                {
                    ParseExports(MsgRemovedExport, args.RemovedExports);
                }

                if (args.ChangedContractNames != null)
                {
                    bool first = true;
                    foreach (string contract in args.ChangedContractNames)
                    {
                        if (first)
                        {
                            LogInfo(MsgChangeContract);
                            first = false;
                        }
                        LogInfo(" ==>{0}", contract);
                    }
                }
            }
            catch (Exception ex)
            {
                LogWarn(ex.Message);
            }
        }
Esempio n. 24
0
 private void ExportProvider_ExportsChanged(object sender, ExportsChangeEventArgs e)
 {
     UpdateTarget();
 }
Esempio n. 25
0
            public void OnExportsChanged(object sender, ExportsChangeEventArgs args)
            {
                Assert.IsTrue(this._expectedAdds != null || this._expectedRemoves != null);

                if (this._expectedAdds == null)
                {
                    EnumerableAssert.IsEmpty(args.AddedExports);
                }
                else
                {
                    foreach (var add in this._expectedAdds)
                    {
                        Assert.IsTrue(this._container.IsPresent(add), "Added exports should be added during changed");
                    }
                }

                if (this._expectedRemoves == null)
                {
                    EnumerableAssert.IsEmpty(args.RemovedExports);
                }
                else
                {
                    foreach (var remove in this._expectedRemoves)
                    {
                        Assert.IsFalse(this._container.IsPresent(remove), "Removed exports should be removed during changed");
                    }
                }

                Assert.IsNull(args.AtomicComposition);

                this._changedEventCount++;
            }
Esempio n. 26
0
 private void ModuleContainerOnExportsChanged(object sender, ExportsChangeEventArgs exportsChangeEventArgs)
 {
     Trace.TraceInformation("Module container exports changed");
 }