Esempio n. 1
0
        /// <summary>
        /// 加载插件
        /// </summary>
        public void LoadPlugins()
        {
            Plugin plugin = null;

            if (AudioPlugInfos.Count == 0)
            {
                Log.Write("缺少音频插件!");
            }
            else
            {
                plugin = loadCSharpPlugin(AudioPlugInfos[0] as PlugInfo);
                PluginsContainer.Add(plugin.PlugInfo.Id, plugin);
            }
            foreach (var item in CurrencyPlugInfos)
            {
                plugin = loadCSharpPlugin(item as PlugInfo);
                PluginsContainer.Add(plugin.PlugInfo.Id, plugin);
            }
            if (FacePlugInfos.Count == 0)
            {
                Log.Write("缺少界面插件!");
            }
            else
            {
                plugin = loadCSharpPlugin(FacePlugInfos[0] as PlugInfo);
                PluginsContainer.Add(plugin.PlugInfo.Id, plugin);
            }
        }
Esempio n. 2
0
        private static void Initialize()
        {
            TestWebServer.EnsureTestAssembly();

            TestFramework.EnsureCorrectVersion(TestWebServer.GetDependencyContext());

            ValidateStartup();

            TestCounter.SetLicenseData(
                ServerTestConfiguration.Global.Licenses,
                DateTime.UtcNow,
                DateTime.ParseExact(TestFramework.ReleaseDate, "yyyy-MM-dd", CultureInfo.InvariantCulture),
                TestWebServer.TestAssemblyName);

            PluginsContainer.LoadPlugins(TestWebServer.GetDependencyContext());

            var serviceCollection = TestWebServer.GetInitialServiceCollection();

            PrepareStartup(serviceCollection);
            PrepareServices(serviceCollection);

            PrepareApplicationAndRouting();

            initialized = true;
        }
Esempio n. 3
0
        /// <summary>
        /// 加载插件
        /// </summary>
        /// <param name="path"></param>
        private void loadCSharpPlugin(string path)
        {
            string name = Path.GetFileName(path);

            if (!File.Exists(path))
            {
                Log.Write("加载插件", name, "失败, 原因 --> ", "插件路劲下不存在该插件!");
                return;
            }
            try
            {
                Assembly assembly = Assembly.LoadFrom(path);
                Plugin   plugin   = new Plugin();
                plugin.PluginInstance = Activator.CreateInstance(
                    assembly.GetExportedTypes().Where(p => p.GetCustomAttribute <ExportAttribute>() != null).First()
                    ) as IPlugBaseInterface;
                if (plugin is null)
                {
                    Log.Write("加载插件", name, "失败, 原因 --> ", "插件未提供有效的接口!");
                    return;
                }
                PlugInfo plugInfo = new PlugInfo();
                FileInfo info     = new FileInfo(path);
                plugin.PlugInfo    = plugInfo;
                plugInfo.Name      = plugin.PluginInstance.Name;
                plugInfo.LocalURL  = path;
                plugInfo.RemoteURL = "";
                plugInfo.IsInstall = true;
                plugInfo.Size      = info.Length.ToString();
                plugInfo.Version   = assembly.ImageRuntimeVersion;
                plugInfo.DateTime  = info.LastWriteTime;
                plugInfo.Author    = "";

                string id = EncryptWithMD5(name);
                if (!PluginsContainer.ContainsKey(id))
                {
                    PluginsContainer.Add(id, plugin);
                }
                else
                {
                    Log.Write("加载插件", name, "失败, 原因 --> 插件已经加载,重复加载!");
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Write("加载插件", name, "失败, 原因 --> ", ex.Message, "或者导出插件接口没有添加特性ExportAttribute");
            }
        }
Esempio n. 4
0
 private static void Reset()
 {
     initialized            = false;
     startupType            = null;
     startupMethods         = null;
     serviceProvider        = null;
     routingServiceProvider = null;
     router             = null;
     AdditionalServices = null;
     AdditionalApplicationConfiguration = null;
     AdditionalRouting           = null;
     TestServiceProvider.Current = null;
     TestServiceProvider.ClearServiceLifetimes();
     LicenseValidator.ClearLicenseDetails();
     PluginsContainer.Reset();
 }
 public DatabaseGenerator_Accessor(IDslModel dslModel, PluginsContainer<IConceptDatabaseDefinition> plugins)
     : base(null, dslModel, plugins, null, new ConsoleLogProvider(), new DatabaseGeneratorOptions { ShortTransactions = false })
 {
 }
 public DatabaseGenerator_Accessor(IDslModel dslModel, PluginsContainer <IConceptDatabaseDefinition> plugins)
     : base(null, dslModel, plugins, null, new ConsoleLogProvider(), new DatabaseGeneratorOptions {
     ShortTransactions = false
 })
 {
 }
Esempio n. 7
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     PluginsContainer.Clear();
     Cache = null;
 }
Esempio n. 8
0
 public DatabaseGenerator_Accessor(IDslModel dslModel, PluginsContainer<IConceptDatabaseDefinition> plugins)
     : base(null, dslModel, plugins, null, new ConsoleLogProvider())
 {
 }