Beispiel #1
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());
        }
        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())));
        }