Пример #1
0
        void ObservableServiceReferences_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                MockServiceReferenceInfo reference    = (MockServiceReferenceInfo)e.NewItems[0];
                YodiiGraphVertex         pluginVertex = FindOrCreatePluginVertex((PluginInfo)reference.Owner);
                YodiiGraphVertex         refVertex    = FindOrCreateServiceVertex((IServiceInfo)reference.Reference);

                YodiiGraphEdge refEdge = new YodiiGraphEdge(pluginVertex, refVertex, reference)
                {
                    ID = currentId++
                };
                this.AddEdge(refEdge);
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                IServiceReferenceInfo reference = (IServiceReferenceInfo)e.OldItems[0];
                Debug.Assert(reference != null);

                this.RemoveEdgeIf(
                    e2 => e2.IsServiceReference &&
                    e2.Source.IsPlugin && e2.Source.LabPluginInfo.PluginInfo == reference.Owner &&
                    e2.Target.IsService && e2.Target.LabServiceInfo.ServiceInfo == reference.Reference);
            }
            RaiseGraphUpdateRequested();
        }
Пример #2
0
        private void DeleteReferenceButton_Click(object sender, RoutedEventArgs e)
        {
            Button                   button        = sender as Button;
            FrameworkElement         parentElement = button.Parent as FrameworkElement;
            MockServiceReferenceInfo serviceRef    = parentElement.DataContext as MockServiceReferenceInfo;

            serviceRef.Owner.InternalServiceReferences.Remove(serviceRef);
        }
Пример #3
0
        /// <summary>
        /// Set an existing plugin's dependency to an existing service.
        /// </summary>
        /// <param name="plugin">Plugin</param>
        /// <param name="service">Service the plugin depends on</param>
        /// <param name="runningRequirement">How the plugin depends on the service</param>
        internal void SetPluginDependency(PluginInfo plugin, ServiceInfo service, DependencyRequirement runningRequirement)
        {
            Debug.Assert(plugin != null);
            Debug.Assert(service != null);
            Debug.Assert(ServiceInfos.Contains(service));
            Debug.Assert(PluginInfos.Contains(plugin));

            MockServiceReferenceInfo reference = new MockServiceReferenceInfo(plugin, service, runningRequirement);

            plugin.InternalServiceReferences.Add(reference);
        }
Пример #4
0
        /// <summary>
        /// Removes an existing plugin dependency.
        /// </summary>
        /// <param name="plugin">Plugin owner.</param>
        /// <param name="service">Service reference</param>
        internal void RemovePluginDependency(PluginInfo plugin, ServiceInfo service)
        {
            Debug.Assert(plugin != null);
            Debug.Assert(service != null);
            Debug.Assert(ServiceInfos.Contains(service));
            Debug.Assert(PluginInfos.Contains(plugin));

            MockServiceReferenceInfo reference = plugin.InternalServiceReferences.First(x => x.Reference == service);

            if (reference != null)
            {
                plugin.InternalServiceReferences.Remove(reference);
            }
        }
Пример #5
0
        private void ReferenceRequirementComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (e.RemovedItems.Count == 1 && e.AddedItems.Count == 1)
            {
                ComboBox                 box           = sender as ComboBox;
                FrameworkElement         parentElement = box.Parent as FrameworkElement;
                MockServiceReferenceInfo serviceRef    = parentElement.DataContext as MockServiceReferenceInfo;

                DependencyRequirement oldReq = serviceRef.Requirement;
                DependencyRequirement newReq = (DependencyRequirement)e.AddedItems[0];

                serviceRef.Requirement = newReq;
            }
        }
Пример #6
0
        private void ReadPlugin(XmlReader r)
        {
            r.Read();

            PluginInfo p = new PluginInfo(null, AssemblyInfoHelper.ExecutingAssemblyInfo);

            loadedPlugins.Add(p);

            Point pos = new Point();

            pos.X = Double.NaN;
            pos.Y = Double.NaN;

            while (r.Read())
            {
                if (r.IsStartElement() && !r.IsEmptyElement)
                {
                    switch (r.Name)
                    {
                    case "FullName":
                        if (r.Read())
                        {
                            string fullName = r.Value;
                            p.PluginFullName = fullName;
                        }
                        break;

                    case "Service":
                        if (r.Read())
                        {
                            string serviceFullName = r.Value;
                            if (!String.IsNullOrEmpty(serviceFullName))
                            {
                                if (loadedServices.Contains(serviceFullName))
                                {
                                    var service = loadedServices.GetByKey(serviceFullName);
                                    p.Service = service;
                                    service.InternalImplementations.Add(p);
                                }
                                else
                                {
                                    pendingPluginServices.Add(new PendingPluginService(p, serviceFullName));
                                }
                            }
                        }
                        break;

                    case "ServiceReferences":
                        var s = r.ReadSubtree();
                        while (s.Read())
                        {
                            if (s.IsStartElement() && s.Name == "ServiceReference")
                            {
                                string serviceFullName2 = s.GetAttribute("Service");
                                if (!String.IsNullOrEmpty(serviceFullName2))
                                {
                                    DependencyRequirement requirement = (DependencyRequirement)Enum.Parse(typeof(DependencyRequirement), s.GetAttribute("Requirement"));

                                    if (loadedServices.Contains(serviceFullName2))
                                    {
                                        MockServiceReferenceInfo i = new MockServiceReferenceInfo(p, loadedServices.GetByKey(serviceFullName2), requirement);
                                        p.InternalServiceReferences.Add(i);
                                    }
                                    else
                                    {
                                        pendingServiceReferences.Add(new PendingServiceReference(p, serviceFullName2, requirement));
                                    }
                                }
                            }
                        }
                        break;

                    case "X":
                        if (r.Read())
                        {
                            double posX;
                            if (Double.TryParse(r.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out posX))
                            {
                                pos.X = posX;
                            }
                        }
                        break;

                    case "Y":
                        if (r.Read())
                        {
                            double posY;
                            if (Double.TryParse(r.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out posY))
                            {
                                pos.Y = posY;
                            }
                        }
                        break;
                    }
                }
            }

            p.PositionInGraph = pos;
        }
Пример #7
0
        private void ReadService(XmlReader r)
        {
            r.Read();
            string serviceFullName = r.GetAttribute("FullName");

            Debug.Assert(serviceFullName != null, "FullName attribute was found in Service XML element.");

            ServiceInfo s = new ServiceInfo(serviceFullName, AssemblyInfoHelper.ExecutingAssemblyInfo);

            loadedServices.Add(s);

            ServiceInfo generalization = null;

            Point pos = new Point();

            pos.X = Double.NaN;
            pos.Y = Double.NaN;

            while (r.Read())
            {
                if (r.IsStartElement() && !r.IsEmptyElement)
                {
                    switch (r.Name)
                    {
                    case "Generalization":
                        if (r.Read())
                        {
                            string generalizationName = r.Value;
                            if (!String.IsNullOrEmpty(generalizationName))
                            {
                                if (loadedServices.Contains(generalizationName))
                                {
                                    generalization   = loadedServices.GetByKey(generalizationName);
                                    s.Generalization = generalization;
                                }
                                else
                                {
                                    pendingGeneralizations.Add(new PendingGeneralization(s, generalizationName));
                                }
                            }
                        }
                        break;

                    case "X":
                        if (r.Read())
                        {
                            double posX;
                            if (Double.TryParse(r.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out posX))
                            {
                                pos.X = posX;
                            }
                        }
                        break;

                    case "Y":
                        if (r.Read())
                        {
                            double posY;
                            if (Double.TryParse(r.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out posY))
                            {
                                pos.Y = posY;
                            }
                        }
                        break;
                    }
                }
            }

            s.PositionInGraph = pos;

            // Fix pending references of this service
            foreach (var pg in pendingGeneralizations.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                pg.Service.Generalization = s;
                pendingGeneralizations.Remove(pg);
            }

            foreach (var pps in pendingPluginServices.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                pps.Plugin.Service = s;
                s.InternalImplementations.Add(pps.Plugin);
                pendingPluginServices.Remove(pps);
            }

            foreach (var psr in pendingServiceReferences.Where(x => x.PendingServiceFullName == serviceFullName).ToList())
            {
                var reference = new MockServiceReferenceInfo(psr.Plugin, s, psr.Requirement);
                psr.Plugin.InternalServiceReferences.Add(reference);
                pendingServiceReferences.Remove(psr);
            }
        }
Пример #8
0
 internal YodiiGraphEdge(YodiiGraphVertex source, YodiiGraphVertex target, MockServiceReferenceInfo serviceRef)
     : this(source, target, YodiiGraphEdgeType.ServiceReference)
 {
     serviceRef.PropertyChanged += serviceRef_PropertyChanged;
     _referenceRequirement       = serviceRef.Requirement;
 }