Exemplo n.º 1
0
        public void PluginOptionsTest()
        {
            Application.EnableVisualStyles();
            var plugionOptions = new PluginOptions();

            plugionOptions.ShowDialog();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public static bool RegisterQksPlugin(this IServiceCollection services)
        {
            var pluginOpt = new PluginOptions();

            PluginHelper.LoadPlugins(pluginOpt);
            services.AddSingleton(pluginOpt);
            return(pluginOpt.Loaded);
        }
Exemplo n.º 7
0
        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;
                    }
                }
            }
        }
Exemplo n.º 8
0
 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();
 }
Exemplo n.º 9
0
        public static bool RegisterQksPlugin(this IServiceCollection services, IHostingEnvironment hostingEnvironment)
        {
            var pluginOpt = new PluginOptions
            {
                Environment = hostingEnvironment
            };

            PluginHelper.LoadPlugins(pluginOpt);
            services.AddSingleton(pluginOpt);
            return(pluginOpt.Loaded);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        public override void SetOptions(PluginOptions options)
        {
            if (options == null)
            {
                return;
            }
            if (!(options is NamespacesOptions))
            {
                return;
            }

            _options = options as NamespacesOptions;
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        public void SetOptions(PluginOptions options)
        {
            if (options == null)
            {
                return;
            }
            if (!(options is CSParserOptions))
            {
                return;
            }

            _options = options as CSParserOptions;
        }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
 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;
 }
Exemplo n.º 17
0
 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();
     }
 }
Exemplo n.º 18
0
        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());
        }
Exemplo n.º 19
0
        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;
        }
Exemplo n.º 20
0
 public static void UseDocumentService <TDocumentService, TDocument>(this PluginOptions options)
     where TDocumentService : IDocumentService <TDocument>
     where TDocument : class, IDocument
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
 public WebPluginManage(PluginOptions pluginOptions) : base(pluginOptions)
 {
 }
Exemplo n.º 22
0
 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;
 }
Exemplo n.º 23
0
 public PluginsHostBuilderContext(PluginOptions options, IDictionary <object, object> properties) : base(properties)
 {
     this.Options = options ?? throw new ArgumentNullException(nameof(options));
 }
Exemplo n.º 24
0
 public static void ConfigureGridView(this PluginOptions options, Action <PluginGrid> configure)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 25
0
 public static void UseThumbnail <TView>(this PluginOptions options)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
 public static void UseFolderManager <TFolderManager>(this PluginOptions options) where TFolderManager : IFolderManager
 {
     throw new NotImplementedException();
 }
Exemplo n.º 31
0
 public static void UseFullPage <TView>(this PluginOptions options)
 {
     throw new NotImplementedException();
 }
 public TestPluginExecutorImplementation(string name, List<string> aliases, PluginOptions pluginOptions)
     : base(name, aliases, pluginOptions)
 {
 }