示例#1
0
        public static ManifestFile FromRepository(WoWRepository repository)
        {
            try
            {
                var manifest = new ManifestFile();
                var client   = new WebClient();

                string content = client.DownloadString(repository.GetBaseUrl() + repository.GetMFilName());

                string[] lines = content.Split('\n');

                foreach (string line in lines)
                {
                    if (line.Trim().StartsWith("version="))
                    {
                        int output;
                        if (int.TryParse(line.Trim().Replace("version=", ""), out output))
                        {
                            manifest.Version = output;
                        }
                    }
                    manifest.Lines.Add(line.Trim().Replace("file=", repository.GetBaseUrl()));
                }

                return(manifest);
            }
            catch (Exception ex)
            {
                Program.Log("Unable to retrieve Manifest file", ConsoleColor.Red);
                Program.Log(ex.Message, ConsoleColor.Red);
            }
            return(null);
        }
        public static ManifestFile FromRepository(IWoWRepository repository)
        {
            try
            {
                var manifest = new ManifestFile();
                var client = new WebClient();

                string content = client.DownloadString(repository.GetBaseUrl() + repository.GetMFilName());

                string[] lines = content.Split('\n');

                foreach (string line in lines)
                {
                    if (line.Trim().StartsWith("version="))
                    {
                        int output;
                        if (int.TryParse(line.Trim().Replace("version=", ""), out output))
                        {
                            manifest.Version = output;
                        }
                    }
                    manifest.Lines.Add(line.Trim().Replace("file=", repository.GetBaseUrl()));
                }

                return manifest;
            }
            catch (Exception ex)
            {
                Program.Log("Unable to retrieve Manifest file", ConsoleColor.Red);
                Program.Log(ex.Message, ConsoleColor.Red);
            }
            return null;
        }
        private static void StartProcess(ManifestFile manifest)
        {
            Program.Log("Generating file list");
            IWoWRepository repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil);
            List<FileObject> files = manifest.GenerateFileList();

            var downloader = new FileDownloader(repository, files);
            downloader.Start();
            CurrentSession.SessionCompleted = true;
            CurrentSession.SaveSession();
            CurrentSession.Destroy();
            Program.Log("Download Complete !!", ConsoleColor.Green);
        }
示例#4
0
 public static string SelectLocale(ManifestFile manifest)
 {
     List<string> locales = manifest.GetLocales();
     Program.Log("Which locale do you want to use :");
     Program.Log();
     foreach (string item in locales)
     {
         Program.Log("[" + (locales.IndexOf(item) + 1).ToString("00") + "] " + item);
     }
     Program.Log();
     Program.Log("Select locale :");
     int selectedIndex = HandleUserParams(locales.Count);
     return locales[selectedIndex];
 }