示例#1
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())));
        }
示例#2
0
        public string ExecuteCommand(string commandLine)
        {
            String  bundleIdStr = commandLine.Substring(GetCommandName().Length).Trim();
            var     bundleId    = int.Parse(bundleIdStr);
            IBundle bundle      = context.GetBundle(bundleId);

            if (bundle == null)
            {
                return(String.Format("未找到ID为[{0}]的Bundle", bundleId));
            }
            bundle.Stop();
            return(String.Format("插件[{0} ({1})]已停止.当前状态为:{2}", bundle.GetSymbolicName(), bundle.GetVersion(), BundleUtils.GetBundleStateString(bundle.GetState())));
        }
示例#3
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()));
        }
示例#4
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()));
        }
示例#5
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()));
        }
示例#6
0
 /// <summary>
 /// 根据程序集名称获取已装载的指定Bundle
 /// </summary>
 /// <param name="assemblyName">程序集名称</param>
 /// <returns>Bundle模块</returns>
 public IBundle GetBundle(string assemblyName)
 {
     return(framework.GetBundles().FirstOrDefault(bundle => bundle.GetSymbolicName().Equals(assemblyName)));
 }