public void PluginOptionsTest() { Application.EnableVisualStyles(); var plugionOptions = new PluginOptions(); plugionOptions.ShowDialog(); }
public static HttpConfiguration Configure(PluginOptions options) { var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.SuppressDefaultHostAuthentication(); config.MessageHandlers.Insert(0, new KatanaDependencyResolver()); config.Services.Add(typeof(IExceptionLogger), new LogProviderExceptionLogger()); config.Services.Replace(typeof(IHttpControllerTypeResolver), new HttpControllerTypeResolver()); config.Formatters.Remove(config.Formatters.XmlFormatter); config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly; if (options.IdentityServerOptions.LoggingOptions.EnableWebApiDiagnostics) { var liblog = new TraceSource("LibLog"); liblog.Switch.Level = SourceLevels.All; liblog.Listeners.Add(new LibLogTraceListener()); var diag = config.EnableSystemDiagnosticsTracing(); diag.IsVerbose = options.IdentityServerOptions.LoggingOptions.WebApiDiagnosticsIsVerbose; diag.TraceSource = liblog; } if (options.IdentityServerOptions.LoggingOptions.EnableHttpLogging) { config.MessageHandlers.Add(new RequestResponseLogger()); } return(config); }
public PluginPackage(Stream stream, string packagePath, PluginOptions pluginOptions) { _zipStream = stream; _packagePath = packagePath; _pluginOptions = pluginOptions; Initialize(stream); }
public PluginPackageManager(IHostEnvironment environment, IOptions <PluginOptions> options) { _hostEnvironment = environment; _pluginOptions = options.Value; //_baseDirectory = AppContext.BaseDirectory; _baseDirectory = environment.ContentRootPath; }
private PluginsHostBuilderContext GetPluginsBuilderContext(HostBuilderContext context) { if (!context.Properties.TryGetValue(typeof(PluginsHostBuilderContext), out var contextValue)) { PluginOptions options; if (context.Properties.TryGetValue(typeof(PluginOptions), out var optionsValue)) { options = (PluginOptions)optionsValue; } else { context.Properties[typeof(PluginOptions)] = options = new PluginOptions(context.HostingEnvironment); } var pluginsHostBuilderContext = new PluginsHostBuilderContext(options, context.Properties) { Configuration = context.Configuration, HostingEnvironment = context.HostingEnvironment, }; context.Properties[typeof(PluginsHostBuilderContext)] = pluginsHostBuilderContext; return(pluginsHostBuilderContext); } var pluginsHostContext = (PluginsHostBuilderContext)contextValue; pluginsHostContext.Configuration = context.Configuration; return(pluginsHostContext); }
public static bool RegisterQksPlugin(this IServiceCollection services) { var pluginOpt = new PluginOptions(); PluginHelper.LoadPlugins(pluginOpt); services.AddSingleton(pluginOpt); return(pluginOpt.Loaded); }
internal void GetAllOptions(List <PluginOptions> result, List <PluginOptions> resultParserOptions) { if (result == null) { _windowManager.Logger.LogStr("Error : empty options list"); return; } // Get options from plugins. The plugins give us a specialized options class. result.Clear(); foreach (KeyValuePair <string, IWindowPlugin> pair in _windowPlugins) { string id = string.Empty; try { id = pair.Value.GetID(); PluginOptions options = pair.Value.GetOptions(); if (options != null) { options.PluginId = id; result.Add(options); } } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Failed getting plugin options :" + id)) { throw; } } } resultParserOptions.Clear(); foreach (KeyValuePair <string, IParserPlugin> pair in _parserPlugins) { string id = string.Empty; try { id = pair.Value.GetID(); PluginOptions options = pair.Value.GetOptions(); if (options != null) { options.PluginId = id; resultParserOptions.Add(options); } } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Failed getting parser plugin options :" + id)) { throw; } } } }
public PluginManage(PluginOptions pluginOptions) { this._plutinType = typeof(TPlugin); this._store = new ConcurrentDictionary <string, IPlugin>(); this._pluginDir = this.AbsolutePath(pluginOptions.Path) ? pluginOptions.Path : Path.Combine(AppContext.BaseDirectory, pluginOptions.Path); this.LoadPlugin(); }
public static bool RegisterQksPlugin(this IServiceCollection services, IHostingEnvironment hostingEnvironment) { var pluginOpt = new PluginOptions { Environment = hostingEnvironment }; PluginHelper.LoadPlugins(pluginOpt); services.AddSingleton(pluginOpt); return(pluginOpt.Loaded); }
private void ConfigurePlugins(IAppBuilder pluginApp, IdentityServerOptions options) { var pluginOptions = new PluginOptions(options) { CompanyId = "CompanyId", CreateTokenUrl = "http://token.org/createtoken/url", SharedSecret = "SharedSecret", TokenLoginUrl = "http://token.org/login/url" }; pluginApp.UsePlugin(pluginOptions); }
public override void SetOptions(PluginOptions options) { if (options == null) { return; } if (!(options is NamespacesOptions)) { return; } _options = options as NamespacesOptions; }
protected void AddAppPlugins(Type[] allTypes, PluginOptions pluginOptions) { var iAppTy = typeof(IAppPlugin); foreach (var ty in allTypes.Where(x => iAppTy.IsAssignableFrom(x) && !x.IsAbstract)) { var del = CreateConstructorDelegate <IAppPlugin>(ty); var exec = new AppPluginExecutor(ty.FullName, new List <string> { ty.FullName, ty.Name }, del, pluginOptions); this.AppExecutors.Add(exec); } }
public void SetOptions(PluginOptions options) { if (options == null) { return; } if (!(options is CSParserOptions)) { return; } _options = options as CSParserOptions; }
protected PluginExecutor(string name, List <string> aliases, PluginOptions pluginOptions) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("No name provided."); } if (aliases == null || aliases.Count == 0) { throw new ArgumentException("No aliases provided."); } this.name = name; this.aliases = aliases.Distinct().ToList(); this.pluginOptions = pluginOptions; }
internal PluginOptions GetPluginOptions(string pluginID) { PluginOptions result = null; if (_parserPlugins.ContainsKey(pluginID)) { result = _parserPlugins[pluginID].GetOptions(); } else if (_windowPlugins.ContainsKey(pluginID)) { result = _windowPlugins[pluginID].GetOptions(); } return(result); }
public MvcModuleSetup(ApplicationPartManager partManager, IReferenceLoader referenceLoader, IPluginsAssemblyLoadContexts pluginsLoadContexts, DynamicChangeTokenProvider dynamicChangeTokenProvider, INotificationRegister notificationRegister, IOptions <PluginOptions> options, IWebHostEnvironment webHostEnvironment, IRazorViewEngine razorViewEngine, IViewCompilerProvider viewCompiler) { _partManager = partManager; _referenceLoader = referenceLoader; _pluginsLoadContexts = pluginsLoadContexts; _dynamicChangeTokenProvider = dynamicChangeTokenProvider; _notificationRegister = notificationRegister; _pluginOptions = options.Value; _env = webHostEnvironment; //_baseDirectory = AppContext.BaseDirectory; _baseDirectory = _env.ContentRootPath; _razorViewEngine = razorViewEngine; _viewCompiler = viewCompiler; }
public static void LoadPlugins(PluginOptions opt) { try { bool flag = CopyFiles(opt.PluginPath); //string pluginPath = GetPluginPath(); //LoadAssembly(pluginPath, QksConsts.Plugin.Core); //LoadAssembly(pluginPath, QksConsts.Plugin.Application); //LoadAssembly(pluginPath, QksConsts.Plugin.EFCore); opt.Loaded = flag; opt.LoadMsg = flag ? "插件加载成功" : "没有找到任何插件"; } catch (Exception e) { opt.LoadMsg = e.ToString(); } }
public static IContainer Configure(PluginOptions options) { if (options == null) { throw new ArgumentNullException("options"); } var factory = options.Factory; factory.Validate(); var builder = new ContainerBuilder(); // mandatory from factory builder.Register(factory.UserService); // general services builder.RegisterInstance(options).AsSelf(); builder.RegisterInstance(options.IdentityServerOptions).AsSelf(); // load core controller builder.RegisterApiControllers(typeof(IdSrvPluginController).Assembly); builder.Register <OwinEnvironmentService>(resolver => new OwinEnvironmentService(resolver.Resolve <IOwinContext>().Environment)); // services builder.RegisterType <SerializationService>().As <ISerializationService>(); builder.RegisterType <HttpClientService>().As <IHttpClientService>(); // register additional dependencies from identity server foreach (var registration in options.IdentityServerOptions.Factory.Registrations) { builder.Register(registration); } // add any additional dependencies from hosting application foreach (var registration in factory.Registrations) { builder.Register(registration, registration.Name); } return(builder.Build()); }
internal OptionsBrowser(IServiceProvider serviceProvider) { InitializeComponent(); _windowManager = (WindowManager)serviceProvider.GetService(typeof(WindowManager)); listBox1.Items.Clear(); listBox1.Items.Add(new ListBoxItem("", false, false, "Main", _windowManager.AppOptions)); foreach (IParserPlugin plugin in _windowManager.PluginManager.ParserPlugins) { PluginOptions po = plugin.GetOptions(); listBox1.Items.Add(new ListBoxItem(plugin.GetID(), true, false, plugin.GetID(), po)); } foreach (IWindowPlugin plugin in _windowManager.PluginManager.WindowPlugins) { PluginOptions po = plugin.GetOptions(); listBox1.Items.Add(new ListBoxItem(plugin.GetID(), false, true, plugin.GetID(), po)); } listBox1.SelectedIndex = 0; }
public static void UseDocumentService <TDocumentService, TDocument>(this PluginOptions options) where TDocumentService : IDocumentService <TDocument> where TDocument : class, IDocument { throw new NotImplementedException(); }
public WebPluginManage(PluginOptions pluginOptions) : base(pluginOptions) { }
public ApiPluginExecutor(string name, List <string> aliases, Func <IApiPlugin> creator, PluginOptions pluginOptions) : base(name, aliases, pluginOptions) { if (creator == null) { throw new ArgumentNullException("Creator cannot be null."); } this.createPlugin = creator; }
public PluginsHostBuilderContext(PluginOptions options, IDictionary <object, object> properties) : base(properties) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); }
public static void ConfigureGridView(this PluginOptions options, Action <PluginGrid> configure) { throw new NotImplementedException(); }
public static void UseThumbnail <TView>(this PluginOptions options) { throw new NotImplementedException(); }
public static void UseEditForm <TView>(this PluginOptions options) { throw new NotImplementedException(); }
/// <summary> /// 构造一个 <see cref="AbstractPluginResolver"/>。 /// </summary> /// <param name="options">给定的 <see cref="PluginOptions"/>。</param> protected AbstractPluginResolver(PluginOptions options) { _options = options; }
public ApiPluginExecutor(string name, List<string> aliases, Func<IApiPlugin> creator, PluginOptions pluginOptions) : base(name, aliases, pluginOptions) { if (creator == null) throw new ArgumentNullException("Creator cannot be null."); this.createPlugin = creator; }
public static IApplicationBuilder UsePlugin(this IApplicationBuilder applicationBuilder) { var serviceProvider = applicationBuilder.ApplicationServices; PluginOptions _pluginOptions = serviceProvider.GetService <IOptions <PluginOptions> >().Value; if (!_pluginOptions.Enable) { return(applicationBuilder); } MvcRazorRuntimeCompilationOptions option = serviceProvider.GetService <IOptions <MvcRazorRuntimeCompilationOptions> >()?.Value; var pluginsLoadContexts = serviceProvider.GetService <IPluginsAssemblyLoadContexts>(); //AssemblyLoadContextResoving(pluginsLoadContexts); IReferenceLoader loader = serviceProvider.GetService <IReferenceLoader>(); var moduleSetup = serviceProvider.GetService <IMvcModuleSetup>(); IPluginManagerService pluginManager = serviceProvider.GetService <IPluginManagerService>(); List <PluginInfoDto> allEnabledPlugins = pluginManager.GetAllPlugins().ConfigureAwait(false).GetAwaiter().GetResult(); ModuleChangeDelegate moduleStarted = (moduleEvent, context) => { if (context?.PluginContext == null || context?.PluginContext.PluginEntityAssemblies.Count() == 0) { return; } //var pluginContexts = pluginsLoadContexts.All().Select(c => c.PluginContext).SkipWhile(c => c == null); switch (moduleEvent) { case ModuleEvent.Installed: HandleModuleInstallEvent(serviceProvider, context); break; case ModuleEvent.Loaded: HandleModuleLoadEvent(serviceProvider, context); break; case ModuleEvent.Started: break; case ModuleEvent.Stoped: break; case ModuleEvent.UnInstalled: HandleModuleUnintallEvent(serviceProvider, context); break; default: break; } }; moduleSetup.ModuleChangeEventHandler += moduleStarted; var env = serviceProvider.GetService <IHostEnvironment>(); foreach (var plugin in allEnabledPlugins) { string filePath = Path.Combine(env.ContentRootPath, _pluginOptions.InstallBasePath, plugin.Name, $"{ plugin.Name}.dll"); //option.FileProviders.Add(new PhysicalFileProvider(Path.Combine(AppContext.BaseDirectory, _pluginOptions.InstallBasePath, plugin.Name))); option.AdditionalReferencePaths.Add(filePath); if (plugin.IsEnable) { moduleSetup.EnableModule(plugin.Name); } else { moduleSetup.LoadModule(plugin.Name, false); } } AdditionalReferencePathHolder.AdditionalReferencePaths = option?.AdditionalReferencePaths; var razorViewEngineOptions = serviceProvider.GetService <IOptions <RazorViewEngineOptions> >()?.Value; razorViewEngineOptions?.AreaViewLocationFormats.Add("/Plugins/{2}/Views/{1}/{0}" + RazorViewEngine.ViewExtension); razorViewEngineOptions?.AreaViewLocationFormats.Add("/Views/Shared/{0}.cshtml"); return(applicationBuilder); }
public static void UseFolderManager <TFolderManager>(this PluginOptions options) where TFolderManager : IFolderManager { throw new NotImplementedException(); }
public static void UseFullPage <TView>(this PluginOptions options) { throw new NotImplementedException(); }
public TestPluginExecutorImplementation(string name, List<string> aliases, PluginOptions pluginOptions) : base(name, aliases, pluginOptions) { }