Beispiel #1
0
 private void _tvView_OnDeleteEngine(EngineSchema obj)
 {
     if (currentlySelectedShip == null)
     {
         return;
     }
     OnDelete(currentlySelectedShip.Engines, obj);
 }
Beispiel #2
0
        void IInitializeService.Initialize()
        {
            preferred_engine_id = EngineSchema.Get();

            if (default_engine == null && engines.Count > 0)
            {
                default_engine = engines[0];
            }

            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/Banshee/MediaEngine/PlayerEngine"))
            {
                LoadEngine(node);
            }

            if (default_engine != null)
            {
                active_engine = default_engine;
                Log.Debug(Catalog.GetString("Default player engine"), active_engine.Name);
            }
            else
            {
                default_engine = active_engine;
            }

            if (default_engine == null || active_engine == null || engines == null || engines.Count == 0)
            {
                Log.Warning(Catalog.GetString(
                                "No player engines were found. Please ensure Banshee has been cleanly installed."),
                            "Using the featureless NullPlayerEngine.");
                PlayerEngine null_engine = new NullPlayerEngine();
                LoadEngine(null_engine);
                active_engine  = null_engine;
                default_engine = null_engine;
            }

            MetadataService.Instance.HaveResult += OnMetadataServiceHaveResult;

            TrackInfo.IsPlayingMethod = track => IsPlaying(track) &&
                                        track.CacheModelId == CurrentTrack.CacheModelId &&
                                        (track.CacheEntryId == null || track.CacheEntryId.Equals(CurrentTrack.CacheEntryId));
        }
Beispiel #3
0
        public async Task <EngineSchema> ComposeAsync(EngineSettings settings, EngineDescriptor descriptor)
        {
            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug("Composing schema");
            }

            var featureNames = descriptor.Features.Select(x => x.Id).ToArray();

            var features = await _pluginManager.LoadFeaturesAsync(featureNames);

            var entries = new Dictionary <Type, FeatureEntry>();

            foreach (var feature in features)
            {
                foreach (var exportedType in feature.ExportedTypes)
                {
                    var requiredFeatures = RequireFeaturesAttribute.GetRequiredFeatureNamesForType(exportedType);

                    if (requiredFeatures.All(x => featureNames.Contains(x)))
                    {
                        entries.Add(exportedType, feature);
                    }
                }
            }

            var result = new EngineSchema
            {
                Settings     = settings,
                Descriptor   = descriptor,
                Dependencies = entries
            };

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug("Done composing schema");
            }
            return(result);
        }
Beispiel #4
0
        public IServiceProvider CreateContainer(EngineSettings settings, EngineSchema schema)
        {
            var tenantServiceCollection = _serviceProvider.CreateChildContainer(_applicationServices);

            tenantServiceCollection.AddSingleton(settings);
            tenantServiceCollection.AddSingleton(schema.Descriptor);
            tenantServiceCollection.AddSingleton(schema);

            AddCoreServices(tenantServiceCollection);

            var moduleServiceCollection = _serviceProvider.CreateChildContainer(_applicationServices);

            foreach (var dependency in schema.Dependencies.Where(t => typeof(Modules.IStartup).IsAssignableFrom(t.Key)))
            {
                moduleServiceCollection.AddSingleton(typeof(Modules.IStartup), dependency.Key);
                tenantServiceCollection.AddSingleton(typeof(Modules.IStartup), dependency.Key);
            }

            var configuration = new ConfigurationBuilder().AddInMemoryCollection().Build();

            moduleServiceCollection.TryAddSingleton(configuration);
            tenantServiceCollection.TryAddSingleton(configuration);

            moduleServiceCollection.AddSingleton(settings);

            var moduleServiceProvider = moduleServiceCollection.BuildServiceProvider(true);

            var featureAwareServiceCollection = new FeatureAwareServiceCollection(tenantServiceCollection);

            var startups = moduleServiceProvider.GetServices <Modules.IStartup>();

            startups = startups.OrderBy(s => s.Order);

            foreach (var startup in startups)
            {
                var feature = schema.Dependencies.FirstOrDefault(x => x.Key == startup.GetType()).Value?.FeatureInfo;

                featureAwareServiceCollection.SetCurrentFeature(feature ?? _applicationFeature);
                startup.ConfigureServices(featureAwareServiceCollection);
            }

            (moduleServiceProvider as IDisposable).Dispose();

            var engineServiceProvider = tenantServiceCollection.BuildServiceProvider(true);

            var typeFeatureProvider = engineServiceProvider.GetRequiredService <ITypeFeatureProvider>();

            foreach (var featureServiceCollection in featureAwareServiceCollection.FeatureCollections)
            {
                foreach (var serviceDescriptor in featureServiceCollection.Value)
                {
                    if (serviceDescriptor.ImplementationType != null)
                    {
                        typeFeatureProvider.TryAdd(serviceDescriptor.ImplementationType, featureServiceCollection.Key);
                    }
                    else if (serviceDescriptor.ImplementationInstance != null)
                    {
                        typeFeatureProvider.TryAdd(serviceDescriptor.ImplementationInstance.GetType(), featureServiceCollection.Key);
                    }
                    else
                    {
                    }
                }
            }

            return(engineServiceProvider);
        }
 /// <summary>
 /// Initializes a new instance of <seealso cref="EngineSpecification"/> class.
 /// </summary>
 /// <param name="schema">The engine schema.</param>
 /// <param name="optionsSchema">The engine options schema.</param>
 public EngineSpecification(EngineSchema schema, EngineOptionsSchema optionsSchema)
 {
     Schema        = schema;
     OptionsSchema = optionsSchema;
 }
Beispiel #6
0
 public static Engine Construct(EngineSchema engineSchema)
 {
     return(new Engine(engineSchema.Name, engineSchema.MaxHealth, engineSchema.Mass, engineSchema.UpkeepCost, engineSchema.ThrustPower));
 }