Exemple #1
0
        /// <inheritdoc />
        public override bool Bootstrap(IApplicationContext applicationContext)
        {
            try
            {
                // Configure the plugin server
                PluginDirectories.AddRange(
                    applicationContext.StartupOptions.PluginDirectories ?? Array.Empty <string>()
                    );

                // Discover plugins
                var discoveredPlugins = Loader.DiscoverPlugins(applicationContext, PluginDirectories);

                applicationContext.Logger.Info(
                    $"Discovered {discoveredPlugins.Count} plugins:\n{string.Join("\n", discoveredPlugins.Select(plugin => plugin.Key))}"
                    );

                // Load configuration for plugins
                Loader.LoadConfigurations(applicationContext, discoveredPlugins.Values);

                // Register discovered plugins
                RegisterPlugins(discoveredPlugins);

                // Create plugin instances
                CreateInstances();

                // Run bootstrap plugin
                RunOnAllInstances(applicationContext, OnBootstrap);

                return(true);
            }
            catch (Exception exception)
            {
                throw new ServiceLifecycleFailureException(ServiceLifecycleStage.Bootstrap, Name, exception);
            }
        }
        public override ISet <AssetMetaPath> CollectFiles(PluginDirectories dirs)
        {
            var paths = new HashSet <AssetMetaPath>();

            foreach (var path in dirs.CustomSaberDir.EnumerateFiles("*.saber", SearchOption.AllDirectories))
            {
                paths.Add(new AssetMetaPath(path, dirs.Cache.GetFile(path.Name + ".meta").FullName));
            }

            return(paths);
        }
Exemple #3
0
        private RemoteLocationPart(InitData initData, IHttpService webClient, PluginDirectories pluginDirs)
        {
            _webClient      = webClient;
            _customSaberDir = pluginDirs.CustomSaberDir;

            RemoteLocation = initData.RemoteLocation;
            ListName       = initData.Name;
            ListAuthor     = initData.Author + " : <color=green>Download</color>";
            _filename      = initData.Filename;

            if (!string.IsNullOrEmpty(initData.CoverPath))
            {
                var data = Utilities.GetResource(Assembly.GetExecutingAssembly(), initData.CoverPath);
                ListCover = BeatSaberMarkupLanguage.Utilities.LoadSpriteRaw(data);
            }
        }
        public InfrastructureSettingViewModel()
        {
            pluginDirectories   = new ObservableCollection <string>();
            addDirectoryCommand = new RelayCommand(() =>
            {
                if (dialog == null)
                {
                    dialog = new FolderBrowserDialog();
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (PluginDirectories.Any(d => d.Equals(dialog.SelectedPath, StringComparison.OrdinalIgnoreCase)))
                    {
                        MessageBox.Show(GisEditor.LanguageManager.GetStringResource("DirectoryExistsSelectAnotherLabel"), GisEditor.LanguageManager.GetStringResource("DirectoryExistsLabel"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        PluginDirectories.Add(dialog.SelectedPath);
                    }
                }
            });

            removeDirectoryCommand = new ObservedCommand(() =>
            {
                if (!String.IsNullOrEmpty(SelectedDirectory) && PluginDirectories.Contains(SelectedDirectory))
                {
                    int selectedIndex = PluginDirectories.IndexOf(SelectedDirectory);
                    PluginDirectories.Remove(SelectedDirectory);
                    if (PluginDirectories.Count > selectedIndex)
                    {
                        SelectedDirectory = PluginDirectories[selectedIndex];
                    }
                }
            }, () => !String.IsNullOrEmpty(SelectedDirectory));
        }
Exemple #5
0
        private MainAssetStore(
            PluginConfig config,
            SiraLog logger,
            CustomSaberModelLoader customSaberModelLoader,
            PluginDirectories pluginDirs)
        {
            _config     = config;
            _logger     = logger;
            _pluginDirs = pluginDirs;

            _customSaberAssetLoader = new CustomSaberAssetLoader();
            _customSaberModelLoader = customSaberModelLoader;

            _modelCompositions = new Dictionary <string, ModelComposition>();
            _metaData          = new Dictionary <string, PreloadMetaData>();

            foreach (var directory in pluginDirs.CustomSaberDir.GetDirectories("*", SearchOption.AllDirectories))
            {
                var relPath = PathTools.ToRelativePath(directory.FullName);
                relPath = PathTools.CorrectRelativePath(relPath);
                relPath = relPath.Substring(relPath.IndexOf('\\') + 1);
                AdditionalCustomSaberFolders.Add(relPath);
            }
        }
Exemple #6
0
 private TextureStore(PluginDirectories pluginDirs)
 {
     _textureAssets    = new Dictionary <string, TextureAsset>();
     _textureDirectory = pluginDirs.SaberFactoryDir.CreateSubdirectory("Textures");
 }
Exemple #7
0
 /// <summary>
 ///     Get all the loadable file paths
 /// </summary>
 /// <returns></returns>
 public abstract ISet <AssetMetaPath> CollectFiles(PluginDirectories dirs);
 private PresetSaveManager(PluginDirectories pluginDirs, Serializer serializer)
 {
     _serializer = serializer;
     _presetDir  = pluginDirs.PresetDir;
 }
Exemple #9
0
 public static void RegisterPluginDirectory(string path)
 {
     if (path == null) throw new ArgumentNullException(nameof(path));
     PluginDirectories.Add(path);
 }
 protected ConfigBase(PluginDirectories pluginDirs, string fileName)
 {
     ConfigFile = pluginDirs.SaberFactoryDir.GetFile(fileName);
 }
Exemple #11
0
 public TrailConfig(PluginDirectories pluginDirs) : base(pluginDirs, "TrailConfig.json")
 {
 }