コード例 #1
0
        public static async Task <int> Main(string[] args)
        {
            Console.InputEncoding  = Encoding.UTF8;
            Console.OutputEncoding = Encoding.UTF8;

            ILogger             logger     = new Logger();
            ExtensionCollection extensions = new ExtensionCollection();
            {
                extensions.Load(new ExtensionLoader(typeof(Extensions.Builtin.Console.ConsoleExtension).Assembly));
                extensions.Load(new ExtensionLoader(typeof(Extensions.Builtin.Workspace.WorkspaceExtension).Assembly));
            }

            PipelineBuilder <string[], Wrapper <int> > builder = new PipelineBuilder <string[], Wrapper <int> >();

            _ = builder.ConfigureLogger(logger)
                .ConfigureExtensions(extensions)
                .ConfigureHost(new ExtensionHost())
                .ConfigureCliCommand();

            if (Environment == EnvironmentType.Test)
            {
                if (TestView.Input == null)
                {
                    throw new NullReferenceException(nameof(TestView.Input));
                }

                _ = builder.ConfigureConsole(new TestTerminal(), TestView.Input);
            }
            else
            {
                _ = builder.ConfigureConsole(new SystemConsole(), Console.In);
            }

            _ = builder.UseCommandsService().UseReplCommandService();

            _ = builder.UseCliCommand();

            if (Environment == EnvironmentType.Test)
            {
                _ = builder.UseTestView();
            }

            _ = builder.UseReplCommand();

            Pipeline <string[], Wrapper <int> > pipeline = await builder.Build(args, logger);

            PipelineResult <Wrapper <int> > result = await pipeline.Consume();

            if (result.IsOk)
            {
                return(result.Result !);
            }
            else
            {
                Console.Error.WriteLine(result.Exception !.ToString());
                return(-1);
            }
        }
コード例 #2
0
        /// <summary>
        /// Writes the XML file for getting infos about updates.
        /// </summary>
        /// <param name="xmlFile">is the filename where to save the infos to.</param>
        public bool WriteUpdateXml(string xmlFile)
        {
            if (String.IsNullOrEmpty(xmlFile))
            {
                Console.WriteLine("[MpeMaker] Error: Output file for Update.xml is not specified in package.");
                return(false);
            }

            if (!Path.IsPathRooted(xmlFile))
            {
                xmlFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(this.ProjectSettings.ProjectFilename), xmlFile));
            }

            ExtensionCollection list = ExtensionCollection.Load(xmlFile);

            PackageClass pakToAdd = Clone();

            pakToAdd.GeneralInfo.OnlineLocation = ReplaceInfo(pakToAdd.GeneralInfo.OnlineLocation);
            pakToAdd.GeneralInfo.Params.Items.Remove(pakToAdd.GeneralInfo.Params[ParamNamesConst.ICON]);

            list.Add(pakToAdd);
            list.Sort(true);
            list.Save(xmlFile);

            return(true);
        }
コード例 #3
0
        public static Builder UseExtensionsService(this Builder builder) => builder.Use(nameof(UseExtensionsService),
                                                                                        async context =>
        {
            ExtensionCollection res = new ExtensionCollection();
            Manager manager         = context.Services.GetManager();

            res.Load(new ExtensionLoader(typeof(Extensions.Builtin.Console.ConsoleExtension).Assembly));
            res.Load(new ExtensionLoader(typeof(Extensions.Builtin.Workspace.WorkspaceExtension).Assembly));

            foreach (System.Reflection.Assembly v in ExtensionDI.ExtensionAssemblies)
            {
                res.Load(new ExtensionLoader(v));
            }

            await res.LoadFromManager(manager, context.Logs);

            context.Services.Add <ExtensionCollection>(res);
            return(context.IgnoreResult());
        });
コード例 #4
0
        public static void Init()
        {
            InstallerTypeProviders = new Dictionary <string, IInstallerTypeProvider>();
            PathProviders          = new Dictionary <string, IPathProvider>();
            SectionPanels          = new SectionProviderHelper();
            ActionProviders        = new Dictionary <string, IActionType>();
            VersionProviders       = new Dictionary <string, IVersionProvider>();
            ZipProvider            = new ZipProviderClass();


            AddInstallType(new CopyFile());
            AddInstallType(new CopyFont());
            AddInstallType(new GenericSkinFile());

            PathProviders.Add("MediaPortalPaths", new MediaPortalPaths());
            PathProviders.Add("TvServerPaths", new TvServerPaths());
            PathProviders.Add("WindowsPaths", new WindowsPaths());

            AddSection(new Welcome());
            AddSection(new LicenseAgreement());
            AddSection(new ReadmeInformation());
            AddSection(new ImageRadioSelector());
            AddSection(new TreeViewSelector());
            AddSection(new InstallSection());
            AddSection(new Finish());
            AddSection(new GroupCheck());
            AddSection(new GroupCheckScript());

            AddActionProvider(new InstallFiles());
            AddActionProvider(new ShowMessageBox());
            AddActionProvider(new ClearSkinCache());
            AddActionProvider(new RunApplication());
            AddActionProvider(new KillTask());
            AddActionProvider(new CreateShortCut());
            AddActionProvider(new CreateFolder());
            AddActionProvider(new ExtensionInstaller());
            AddActionProvider(new ConfigurePlugin());
            AddActionProvider(new Script());

            AddVersion(new MediaPortalVersion());
            AddVersion(new SkinVersion());
            AddVersion(new TvServerVersion());
            AddVersion(new ExtensionVersion());
            AddVersion(new InstallerVersion());

            InstalledExtensions =
                ExtensionCollection.Load(string.Format("{0}\\InstalledExtensions.xml", BaseFolder));
            KnownExtensions =
                ExtensionCollection.Load(string.Format("{0}\\KnownExtensions.xml", BaseFolder));
        }
コード例 #5
0
        private void add_list_Click(object sender, EventArgs e)
        {
            string xmlFile            = txt_list1.Text;
            ExtensionCollection list  = new ExtensionCollection();
            ExtensionCollection list2 = new ExtensionCollection();

            if (File.Exists(xmlFile))
            {
                list = ExtensionCollection.Load(xmlFile);
            }
            if (File.Exists(txt_list2.Text))
            {
                list2 = ExtensionCollection.Load(txt_list2.Text);
            }
            list.Add(list2);
            list.Save(xmlFile);
        }
コード例 #6
0
 public static Task LoadFromManager(this ExtensionCollection extensions, Manager manager, LoggerScope logger)
 {
     if (manager.HasInitialized)
     {
         foreach (ExtensionMetadata v in manager.GetExtensions())
         {
             try
             {
                 ExtensionLoader loader = new ExtensionLoader(v.RootPath, v.Name);
                 extensions.Load(loader);
             }
             catch
             {
                 logger.Warning($"Load extension at {v.RootPath} failed.");
             }
         }
     }
     return(Task.CompletedTask);
 }
コード例 #7
0
        private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                try
                {
                    MpeCore.MpeInstaller.KnownExtensions.Add(ExtensionCollection.Load(tempFile));
                    File.Delete(tempFile);
                }
                catch (Exception)
                {
                    listBox1.Items.Add("Error to download");
                }
            }
            counter++;

            if (counter >= onlineFiles.Count)
            {
                MpeCore.MpeInstaller.Save();
                Close();
                return;
            }
            NextItem();
        }
コード例 #8
0
 void DownloadThread()
 {
     lock (this) { runningThreads++; }
     try
     {
         string tempFile             = Path.GetTempFileName();
         CompressionWebClient client = new CompressionWebClient();
         int index = -1;
         while (index < onlineFiles.Count && !cancel)
         {
             lock (this)
             {
                 counter++;
                 index = counter;
             }
             if (index >= onlineFiles.Count)
             {
                 return;
             }
             string onlineFile = onlineFiles[index];
             bool   success    = false;
             try
             {
                 client.DownloadFile(onlineFile, tempFile);
                 var extCol = ExtensionCollection.Load(tempFile);
                 lock (this)
                 {
                     MpeCore.MpeInstaller.KnownExtensions.Add(extCol);
                 }
                 success = true;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(string.Format("Error downloading '{0}': {1}", onlineFile, ex.Message));
             }
             Invoke((Action)(() =>
             {
                 progressBar1.Value++;
                 listBox1.Items.Add(string.Format("{0}{1}", success ? "+" : "-", onlineFile));
                 listBox1.SelectedIndex = listBox1.Items.Count - 1;
                 listBox1.SelectedIndex = -1;
             }));
             if (File.Exists(tempFile))
             {
                 File.Delete(tempFile);
             }
         }
     }
     catch { }
     finally
     {
         lock (this)
         {
             runningThreads--;
             if (runningThreads <= 0)
             {
                 MpeCore.MpeInstaller.Save();
                 Invoke((Action)(() =>
                 {
                     DialogResult = cancel ? DialogResult.Cancel : DialogResult.OK;
                     Close();
                 }));
             }
         }
     }
 }