Example #1
0
        public ExtensionsManager(string extensionsConfigFilePath)
        {
            if (string.IsNullOrWhiteSpace(extensionsConfigFilePath))
            {
                return;
            }

            var configFilePath = Path.GetFullPath(extensionsConfigFilePath);

            if (!File.Exists(configFilePath))
            {
                throw new Exception("Extensions config file is not found.");
            }

            var extensionConfig     = JsonConvert.DeserializeObject <ExtensionConfig>(File.ReadAllText(configFilePath));
            var extensionsDirectory = Path.GetDirectoryName(extensionsConfigFilePath);

            foreach (var configItem in extensionConfig.Extensions)
            {
                var extension = ExtensionItem.Load(configItem, extensionsDirectory);
                extension.ExtensionInstance.Init(configItem.ExtensionConfig);

                extensions.Add(extension);
            }
        }
Example #2
0
        public void RegisterAllExtensions()
        {
            if (string.IsNullOrWhiteSpace(Global.Settings.ExtensionsConfigFilePath))
            {
                return;
            }

            var configFilePath = Path.GetFullPath(Global.Settings.ExtensionsConfigFilePath);

            if (!File.Exists(configFilePath))
            {
                throw new Exception("Extensions config file is not found.");
            }

            var extensionConfig = JsonConvert.DeserializeObject <ExtensionConfig>(File.ReadAllText(configFilePath));

            foreach (var configItem in extensionConfig.Extensions)
            {
                var extension = ExtensionItem.Load(configItem);
                extension.ExtensionInstance.Init(configItem.ExtensionConfig);

                extensions.Add(extension);
            }
        }