Пример #1
0
 public PluginRunningStatusReason GetStoppedReasonForStoppedReference( DependencyRequirement requirement )
 {
     StartDependencyImpact impact = _configSolvedImpact;
     switch( requirement )
     {
         case DependencyRequirement.Running: return PluginRunningStatusReason.StoppedByRunningReference;
         case DependencyRequirement.RunnableRecommended:
             if( impact >= StartDependencyImpact.StartRecommended )
             {
                 return PluginRunningStatusReason.StoppedByRunnableRecommendedReference;
             }
             break;
         case DependencyRequirement.Runnable:
             if( impact == StartDependencyImpact.FullStart )
             {
                 return PluginRunningStatusReason.StoppedByRunnableReference;
             }
             break;
         case DependencyRequirement.OptionalRecommended:
             if( impact >= StartDependencyImpact.StartRecommended )
             {
                 return PluginRunningStatusReason.StoppedByOptionalRecommendedReference;
             }
             break;
         case DependencyRequirement.Optional:
             if( impact == StartDependencyImpact.FullStart )
             {
                 return PluginRunningStatusReason.StoppedByOptionalReference;
             }
             break;
     }
     return PluginRunningStatusReason.None;
 }
Пример #2
0
        public PluginDisabledReason GetDisableReasonForDisabledReference(DependencyRequirement req)
        {
            switch (req)
            {
            case DependencyRequirement.Running: return(PluginDisabledReason.ByRunningReference);

            case DependencyRequirement.RunnableRecommended: return(PluginDisabledReason.ByRunnableRecommendedReference);

            case DependencyRequirement.Runnable: return(PluginDisabledReason.ByRunnableReference);

            case DependencyRequirement.OptionalRecommended:
                if (_configSolvedImpact >= StartDependencyImpact.StartRecommended)
                {
                    return(PluginDisabledReason.ByOptionalRecommendedReference);
                }
                break;

            case DependencyRequirement.Optional:
                if (_configSolvedImpact == StartDependencyImpact.FullStart)
                {
                    return(PluginDisabledReason.ByOptionalReference);
                }
                break;
            }
            return(PluginDisabledReason.None);
        }
Пример #3
0
        private void CreateReferenceButton_Click(object sender, RoutedEventArgs e)
        {
            if (LivePluginInfo == null)
            {
                return;
            }

            Button           button        = sender as Button;
            FrameworkElement parentElement = button.Parent as FrameworkElement;

            ComboBox requirementComboBox = parentElement.FindName("NewReferenceRequirementComboBox") as ComboBox;
            ComboBox serviceComboBox     = parentElement.FindName("NewReferenceServiceComboBox") as ComboBox;

            ServiceInfo           service = serviceComboBox.SelectedItem as ServiceInfo;
            DependencyRequirement req     = (DependencyRequirement)requirementComboBox.SelectedItem;

            if (LivePluginInfo.PluginInfo.CanReference(service))
            {
                LivePluginInfo.PluginInfo.InternalServiceReferences.Add(new MockServiceReferenceInfo(LivePluginInfo.PluginInfo, service, req));
            }
            else
            {
                MessageBox.Show("You cannot reference this service.\nMake sure the selected service is in another family, or in the same family branch.", "Reference failed");
            }
        }
Пример #4
0
        public ServiceReferenceInfo AddServiceReference(ServiceInfo service, DependencyRequirement req)
        {
            var r = new ServiceReferenceInfo(this, service, req);

            _serviceReferences.Add(r);
            return(r);
        }
Пример #5
0
        internal ServiceReferenceInfo(IPluginInfo ownerPlugin, IServiceInfo referencedService, DependencyRequirement requirement)
        {
            Debug.Assert(ownerPlugin != null);
            Debug.Assert(referencedService != null);

            _owner       = ownerPlugin;
            _reference   = referencedService;
            _requirement = requirement;
        }
        internal MockServiceReferenceInfo( PluginInfo ownerPlugin, ServiceInfo referencedService, DependencyRequirement requirement )
        {
            Debug.Assert( ownerPlugin != null );
            Debug.Assert( referencedService != null );

            _owner = ownerPlugin;
            _reference = referencedService;
            _requirement = requirement;
        }
Пример #7
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);
        }
Пример #8
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;
            }
        }
Пример #9
0
        public PluginRunningStatusReason GetStoppedReasonForStoppedReference(DependencyRequirement requirement)
        {
            StartDependencyImpact impact = _configSolvedImpact;

            switch (requirement)
            {
            case DependencyRequirement.Running: return(PluginRunningStatusReason.StoppedByRunningReference);

            case DependencyRequirement.RunnableRecommended:
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    return(PluginRunningStatusReason.StoppedByRunnableRecommendedReference);
                }
                break;

            case DependencyRequirement.Runnable:
                if (impact == StartDependencyImpact.FullStart)
                {
                    return(PluginRunningStatusReason.StoppedByRunnableReference);
                }
                break;

            case DependencyRequirement.OptionalRecommended:
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    return(PluginRunningStatusReason.StoppedByOptionalRecommendedReference);
                }
                break;

            case DependencyRequirement.Optional:
                if (impact == StartDependencyImpact.FullStart)
                {
                    return(PluginRunningStatusReason.StoppedByOptionalReference);
                }
                break;
            }
            return(PluginRunningStatusReason.None);
        }
Пример #10
0
 public PluginDisabledReason GetDisableReasonForDisabledReference( DependencyRequirement req )
 {
     switch( req )
     {
         case DependencyRequirement.Running: return PluginDisabledReason.ByRunningReference;
         case DependencyRequirement.RunnableRecommended: return PluginDisabledReason.ByRunnableRecommendedReference;
         case DependencyRequirement.Runnable: return PluginDisabledReason.ByRunnableReference;
         case DependencyRequirement.OptionalRecommended:
             if( _configSolvedImpact >= StartDependencyImpact.StartRecommended )
             {
                 return PluginDisabledReason.ByOptionalRecommendedReference;
             }
             break;
         case DependencyRequirement.Optional:
             if( _configSolvedImpact == StartDependencyImpact.FullStart )
             {
                 return PluginDisabledReason.ByOptionalReference;
             }
             break;
     }
     return PluginDisabledReason.None;
 }
Пример #11
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>
        public void SetPluginDependency( IPluginInfo plugin, IServiceInfo service, DependencyRequirement runningRequirement )
        {
            if( plugin == null ) throw new ArgumentNullException( "plugin" );
            if( service == null ) throw new ArgumentNullException( "service" );

            if( !ServiceInfos.Contains( (ServiceInfo)service ) ) throw new InvalidOperationException( "Service does not exist in this Lab" );
            if( !PluginInfos.Contains( (PluginInfo)plugin ) ) throw new InvalidOperationException( "Plugin does not exist in this Lab" );

            _labStateManager.SetPluginDependency( (PluginInfo)plugin, (ServiceInfo)service, runningRequirement );
        }
Пример #12
0
 public ServiceReferenceInfo AddServiceReference( ServiceInfo service, DependencyRequirement req )
 {
     var r = new ServiceReferenceInfo( this, service, req );
     _serviceReferences.Add( r );
     return r;
 }
Пример #13
0
 internal void DynamicStartByDependency( StartDependencyImpact impact, DependencyRequirement req )
 {
     switch( req )
     {
         case DependencyRequirement.Running:
             {
                 Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                 DynamicStartBy( ServiceRunningStatusReason.StartedByRunningReference );
                 break;
             }
         case DependencyRequirement.RunnableRecommended:
             {
                 if( impact >= StartDependencyImpact.StartRecommended )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByRunnableRecommendedReference );
                 }
                 else if( impact == StartDependencyImpact.FullStop )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByRunnableRecommendedReference );
                 }
                 break;
             }
         case DependencyRequirement.Runnable:
             {
                 if( impact == StartDependencyImpact.FullStart )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByRunnableReference );
                 }
                 else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByRunnableReference );
                 }
                 break;
             }
         case DependencyRequirement.OptionalRecommended:
             {
                 if( impact >= StartDependencyImpact.StartRecommended )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByOptionalRecommendedReference );
                 }
                 else if( impact == StartDependencyImpact.FullStop )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByOptionalRecommendedReference );
                 }
                 break;
             }
         case DependencyRequirement.Optional:
             {
                 if( impact == StartDependencyImpact.FullStart )
                 {
                     Debug.Assert( DynamicCanStart( ConfigSolvedImpact ) );
                     DynamicStartBy( ServiceRunningStatusReason.StartedByOptionalReference );
                 }
                 else if( impact <= StartDependencyImpact.StopOptionalAndRunnable )
                 {
                     Debug.Assert( DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped );
                     DynamicStopBy( ServiceRunningStatusReason.StoppedByOptionalReference );
                 }
                 break;
             }
     }
 }
Пример #14
0
 internal PendingServiceReference( PluginInfo plugin, string pendingServiceFullName, DependencyRequirement requirement )
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
     Requirement = requirement;
 }
Пример #15
0
 internal PendingServiceReference(PluginInfo plugin, string pendingServiceFullName, DependencyRequirement requirement)
 {
     Plugin = plugin;
     PendingServiceFullName = pendingServiceFullName;
     Requirement            = requirement;
 }
Пример #16
0
        private static void ReadPlugin(XmlReader r, DiscoveredInfo d,
                                       CKSortedArrayKeyList <ServiceInfo, string> loadedServices,
                                       CKSortedArrayKeyList <PluginInfo, string> loadedPlugins,
                                       List <PendingPluginService> pendingPluginServices,
                                       List <PendingServiceReference> pendingServiceReferences
                                       )
        {
            r.Read();

            string pluginFullName  = String.Empty;
            string serviceFullName = null;

            List <Tuple <string, DependencyRequirement> > references = new List <Tuple <string, DependencyRequirement> >();

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

                    case "Service":
                        if (r.Read())
                        {
                            serviceFullName = r.Value;
                        }
                        break;

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

                                    references.Add(Tuple.Create(serviceFullName2, requirement));
                                }
                            }
                        }
                        break;
                    }
                }
            }


            PluginInfo p = new PluginInfo(pluginFullName, d.DefaultAssembly);

            d.PluginInfos.Add(p);
            loadedPlugins.Add(p);

            if (!String.IsNullOrEmpty(serviceFullName))
            {
                if (loadedServices.Contains(serviceFullName))
                {
                    var service = loadedServices.GetByKey(serviceFullName);
                    p.Service = service;
                }
                else
                {
                    pendingPluginServices.Add(new PendingPluginService(p, serviceFullName));
                }
            }

            foreach (var t in references)
            {
                if (loadedServices.Contains(t.Item1))
                {
                    p.AddServiceReference(loadedServices.GetByKey(t.Item1), t.Item2);
                }
                else
                {
                    pendingServiceReferences.Add(new PendingServiceReference(p, t.Item1, t.Item2));
                }
            }
        }
Пример #17
0
        internal void DynamicStartByDependency(StartDependencyImpact impact, DependencyRequirement req)
        {
            switch (req)
            {
            case DependencyRequirement.Running:
            {
                Debug.Assert(DynamicCanStart(ConfigSolvedImpact));
                DynamicStartBy(ServiceRunningStatusReason.StartedByRunningReference);
                break;
            }

            case DependencyRequirement.RunnableRecommended:
            {
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    Debug.Assert(DynamicCanStart(ConfigSolvedImpact));
                    DynamicStartBy(ServiceRunningStatusReason.StartedByRunnableRecommendedReference);
                }
                else if (impact == StartDependencyImpact.FullStop)
                {
                    Debug.Assert(DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped);
                    DynamicStopBy(ServiceRunningStatusReason.StoppedByRunnableRecommendedReference);
                }
                break;
            }

            case DependencyRequirement.Runnable:
            {
                if (impact == StartDependencyImpact.FullStart)
                {
                    Debug.Assert(DynamicCanStart(ConfigSolvedImpact));
                    DynamicStartBy(ServiceRunningStatusReason.StartedByRunnableReference);
                }
                else if (impact <= StartDependencyImpact.StopOptionalAndRunnable)
                {
                    Debug.Assert(DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped);
                    DynamicStopBy(ServiceRunningStatusReason.StoppedByRunnableReference);
                }
                break;
            }

            case DependencyRequirement.OptionalRecommended:
            {
                if (impact >= StartDependencyImpact.StartRecommended)
                {
                    Debug.Assert(DynamicCanStart(ConfigSolvedImpact));
                    DynamicStartBy(ServiceRunningStatusReason.StartedByOptionalRecommendedReference);
                }
                else if (impact == StartDependencyImpact.FullStop)
                {
                    Debug.Assert(DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped);
                    DynamicStopBy(ServiceRunningStatusReason.StoppedByOptionalRecommendedReference);
                }
                break;
            }

            case DependencyRequirement.Optional:
            {
                if (impact == StartDependencyImpact.FullStart)
                {
                    Debug.Assert(DynamicCanStart(ConfigSolvedImpact));
                    DynamicStartBy(ServiceRunningStatusReason.StartedByOptionalReference);
                }
                else if (impact <= StartDependencyImpact.StopOptionalAndRunnable)
                {
                    Debug.Assert(DynamicStatus == null || DynamicStatus.Value <= RunningStatus.Stopped);
                    DynamicStopBy(ServiceRunningStatusReason.StoppedByOptionalReference);
                }
                break;
            }
            }
        }
Пример #18
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 );
        }
Пример #19
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;
        }
Пример #20
0
 internal void RegisterPluginReference(PluginData p, DependencyRequirement r)
 {
     _backReferences.Add(new BackReference(p, r));
 }
Пример #21
0
 public BackReference(PluginData p, DependencyRequirement r)
 {
     PluginData  = p;
     Requirement = r;
 }
Пример #22
0
 public BackReference( PluginData p, DependencyRequirement r )
 {
     PluginData = p;
     Requirement = r;
 }
Пример #23
0
 internal void RegisterPluginReference( PluginData p, DependencyRequirement r )
 {
     _backReferences.Add( new BackReference( p, r ) );
 }