コード例 #1
0
        public Servidor Clone()
        {
            Servidor s = new Servidor(/* _config */);

            s.Arma        = arma;
            s.Nombre      = nombre;
            s.PublishedAt = publishedat;
            s.Puerto      = puerto;

            foreach (Mod m in modlist)
            {
                s.ModList.Add(m.Clone());
            }

            return(s);
        }
コード例 #2
0
        private async void readServidores()
        {
            //WinWebDownload dl = new WinWebDownload();

            try
            {
                using (StreamReader r = new StreamReader(Path.Combine(servidores_path.Parent.FullName, "Servidores2.txt")))
                {
                    string l;

                    while (!r.EndOfStream)
                    {
                        l = r.ReadLine();

                        if (l.Length > 0)
                        {
                            if (!l.TrimStart().StartsWith("#"))
                            {
                                Servidor s = new Servidor(/* null */);

                                string[] items = l.Split('|');

                                s.Arma       = items[0];
                                s.Nombre     = items[1];
                                s.IP         = items[2];
                                s.Puerto     = items[3];
                                s.Password   = _pwd_server;
                                s.Repository = items[4];
                                //

                                /*
                                 * string[] lbase = items[5].Length > 0 ? items[5].Split(';') : null;
                                 *
                                 * if (lbase != null)
                                 * {
                                 *  foreach (string m in lbase)
                                 *  {
                                 *      DirectoryInfo d = _bay.GetDirectoryForRepo(m);
                                 *
                                 *      ServidoresData.Mod mo = new ServidoresData.Mod();
                                 *      mo.Nombre = d.FullName;
                                 *      s.ModList.Add(mo);
                                 *  }
                                 * }
                                 */
                                //
                                string[] lmods = items[5].Length > 0 ? items[5].Split(';') : null;

                                if (lmods != null)
                                {
                                    foreach (string m in lmods)
                                    {
                                        Mod mo = new Mod();

                                        // Si empieza por % es un repo completo
                                        if (m.StartsWith(@"%"))
                                        {
                                            //WinWebDownload dl2 = new WinWebDownload();

                                            string repostr = m.Trim('%');
                                            string trg     = "";
                                            string fname   = "";

                                            var parcial = repostr.Split(':');

                                            repostr = parcial[0];

                                            if (parcial.Length > 1)
                                            {
                                                fname = parcial[1] + @".txt";
                                                trg   = Path.Combine(repostr, fname);
                                            }
                                            else
                                            {
                                                fname = "modorder.txt";
                                                trg   = Path.Combine(repostr, fname);
                                            }

                                            string targetdir = Path.Combine(servidores_path.Parent.FullName, "Repositories", repostr);

                                            if (!Directory.Exists(targetdir))
                                            {
                                                Directory.CreateDirectory(targetdir);
                                            }

                                            //dl2.DownloadFile(webrepository, trg, Path.Combine(servidores_path.Parent.FullName, "Repositories", trg));

                                            await DownloadAsync($"{webrepository}/{trg}", $"{Path.Combine(servidores_path.Parent.FullName)}/Repositories/{trg}");


                                            StreamReader morder = new StreamReader(Path.Combine(servidores_path.Parent.FullName, "Repositories", repostr, fname));

                                            string linea;

                                            while ((linea = morder.ReadLine()) != null)
                                            {
                                                Mod mm = new Mod();
                                                mm.Nombre         = linea;
                                                mm.FromRepository = repostr;
                                                s.ModList.Add(mm);
                                            }

                                            morder.Close();
                                        }
                                        else
                                        {
                                            mo.Nombre = m;
                                            s.ModList.Add(mo);
                                        }
                                    }
                                }

                                _servidores.Add(s);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }