예제 #1
0
        public TestForm(IFramework framework)
        {
            string fullName1  = typeof(IDBServices).Assembly.FullName;
            string fulllName2 = typeof(BunderServicesProvider).Assembly.FullName;

            dBServices   = framework.GetBundleContext().GetService <IDBServices>();
            eventService = framework.GetBundleContext().GetService <IEventService>();
            eventService.registListener(this);
            BunderServicesProvider instance = BunderServicesProvider.getInstance();

            // 获取当前线程上下文
            synchronizationContext = SynchronizationContext.Current;
            InitializeComponent();
        }
예제 #2
0
        public string ExecuteCommand(string commandLine)
        {
            var           bundles = framework.GetBundleContext().GetBundles();
            StringBuilder sb      = new StringBuilder();

            sb.Append("Index".PadLeft(5));
            sb.Append("|");
            sb.Append("State".PadRight(12));
            sb.Append("|");
            sb.Append("Name");
            sb.AppendLine();
            var index = 0;

            foreach (IBundle bundle in bundles)
            {
                sb.Append(index.ToString().PadLeft(5));
                sb.Append("|");
                sb.Append(BundleUtils.GetBundleStateString(bundle.GetState()).PadRight(12));
                sb.Append("|");
                sb.Append(String.Format("{0} ({1}) \"{2}\"", bundle.GetSymbolicName(), bundle.GetVersion(), bundle.GetManifest()["Name"]));
                sb.AppendLine();
                index++;
            }
            return(sb.ToString());
        }
예제 #3
0
        public string ExecuteCommand(string commandLine)
        {
            var context = framework.GetBundleContext();

            DBservice    = context.GetService <IDBServices>();
            EventService = context.GetService <IEventService>();
            LogService   = context.GetService <ILogService>();
            return("hello! Test");
        }
예제 #4
0
        public void initFramework()
        {
            var frameworkFactory = new FrameworkFactory();

            framework = frameworkFactory.CreateFramework();

            framework.Init();
            framework.Start();

            bundles = framework.GetBundleContext().GetBundles();
        }
예제 #5
0
 public PluginDetailForm(IFramework framework, string bundleName, string bundleState)
 {
     this.bundleName  = bundleName;
     this.bundleState = bundleState;
     bundle           = framework.GetBundleContext().GetBundle(bundleName);
     this.framework   = framework;
     logService       = BunderServicesProvider.LogService;
     logger           = logService.GetLogger();
     InitializeComponent();
     stateDetialLabel.Text = bundleState;
 }
예제 #6
0
        public string ExecuteCommand(string commandLine)
        {
            String  bundleIdStr = commandLine.Substring(GetCommandName().Length).Trim();
            var     bundleId    = int.Parse(bundleIdStr);
            IBundle bundle      = framework.GetBundleContext().GetBundle(bundleId);

            if (bundle == null)
            {
                return(String.Format("未找到Index为[{0}]的插件", bundleId));
            }
            bundle.Start();
            return(String.Format("启动插件[{0} ({1})]完成,当前状态为:{2}", bundle.GetSymbolicName(), bundle.GetVersion(), BundleUtils.GetBundleStateString(bundle.GetState())));
        }
예제 #7
0
        public string ExecuteCommand(string commandLine)
        {
            String  bundleIdStr = commandLine.Substring(GetCommandName().Length).Trim();
            var     bundleId    = int.Parse(bundleIdStr);
            IBundle bundle      = framework.GetBundleContext().GetBundle(bundleId);

            if (bundle == null)
            {
                return(String.Format("未找到Index为[{0}]的Bundle", bundleId));
            }
            bundle.Stop();
            bundle.UnInstall();
            return(String.Format("插件[{0} ({1})]已卸载.", bundle.GetSymbolicName(), bundle.GetVersion()));
        }
예제 #8
0
        public string ExecuteCommand(string commandLine)
        {
            String  location = commandLine.Substring(GetCommandName().Length).Trim();
            IBundle bundle   = null;

            try
            {
                bundle = framework.GetBundleContext().InstallBundle(location);
            }
            catch (Exception ex)
            {
                return(String.Format("安装插件出错,原因:{0}", ex.Message));
            }
            return(String.Format("插件[{0} ({1})]已安装.", bundle.GetSymbolicName(), bundle.GetVersion()));
        }
예제 #9
0
        public string ExecuteCommand(string commandLine)
        {
            String args = commandLine.Substring(GetCommandName().Length).Trim();

            int    bundleId = 0;
            string location = null;

            if (args.Contains(" "))
            {
                Int32 spaceIndex = args.IndexOf(" ");
                bundleId = int.Parse(args.Substring(0, spaceIndex));
                location = args.Substring(spaceIndex).Trim();
            }
            else
            {
                return("输入内容有误!");
            }

            IBundle bundle = null;

            try
            {
                bundle = framework.GetBundleContext().GetBundle(bundleId);
                if (bundle == null)
                {
                    return(String.Format("未找到Index为[{0}]的插件", bundleId));
                }
                if (!File.Exists(location))
                {
                    return(String.Format("无法找到路径[{0}]对应的文件", location));
                }

                bundle.Update(location);
            }
            catch (Exception ex)
            {
                return(String.Format("更新插件出错,原因:{0}", ex.Message));
            }
            return(String.Format("插件[{0} ({1})]已更新.", bundle.GetSymbolicName(), bundle.GetVersion()));
        }
예제 #10
0
 // 获取服务实例
 private void initServices(IFramework framework)
 {
     dBServices = framework.GetBundleContext().GetService <IDBServices>();
 }