Exemple #1
0
        public IKernel Load(IKernel kernel)
        {
            var executableLocation    = _assemblyService.GetEntryAssembly().Location;
            var additionalPluginsPath = _pathService.Combine(_pathService.GetDirectoryName(executableLocation), "Plugins");

            if (!_directoryService.Exists(additionalPluginsPath))
            {
                _directoryService.CreateDirectory(additionalPluginsPath);
            }

            kernel.Bind(x => x
                        .FromAssembliesInPath(additionalPluginsPath)
                        .SelectAllClasses()
                        .InheritedFrom <IPlugin>()
                        .BindDefaultInterfaces()
                        .Configure(y => y.InTransientScope()));

            return(kernel);
        }
        private void bindAdditionalPlugins()
        {
            _assemblyService  = _kernel.Get <IAssemblyService>();
            _directoryService = _kernel.Get <IDirectoryService>();
            _pathService      = _kernel.Get <IPathService>();

            var executableLocation    = _assemblyService.GetEntryAssembly().Location;
            var additionalPluginsPath = _pathService.Combine(_pathService.GetDirectoryName(executableLocation), "Plugins");

            if (!_directoryService.Exists(additionalPluginsPath))
            {
                _directoryService.CreateDirectory(additionalPluginsPath);
            }

            _kernel.Bind(x => x
                         .FromAssembliesInPath(additionalPluginsPath)
                         .SelectAllClasses()
                         .InheritedFrom <IPlugin>()
                         .BindDefaultInterfaces()
                         .Configure(y => y.InTransientScope()));
        }