示例#1
0
 private static void SaveWithRetry(string fileName, Nikse.SubtitleEdit.Core.Language language)
 {
     for (var i = 0; i < 10; i++)
     {
         try
         {
             language.Save(fileName);
             return;
         }
         catch
         {
             System.Threading.Thread.Sleep(10);
         }
     }
     language.Save(fileName);
 }
示例#2
0
        private static int Main(string[] args)
        {
            var myName = Environment.GetCommandLineArgs()[0];
            myName = Path.GetFileNameWithoutExtension(string.IsNullOrWhiteSpace(myName) ? System.Reflection.Assembly.GetEntryAssembly().Location : myName);
            if (args.Length != 2)
            {
                Console.Write("Usage: " + myName + @" <LanguageMaster> <LanguageDeserializer>
              <LanguageMaster>       Path to the LanguageMaster xml file (LanguageMaster.xml)
              <LanguageDeserializer> Path to the LanguageDeserializer source code file (LanguageDeserializer.cs)
            ");
                return 1;
            }

            Console.Write(WorkInProgress);

            try
            {
                int noOfChanges = 0;

                var language = new Nikse.SubtitleEdit.Core.Language { General = { Version = FindVersionNumber() } };
                var languageAsXml = language.GetCurrentLanguageAsXml();
                var oldLanguageAsXml = string.Empty;
                if (File.Exists(args[0]))
                    oldLanguageAsXml = File.ReadAllText(args[0]);
                if (oldLanguageAsXml != languageAsXml)
                {
                    language.Save(args[0]);
                    noOfChanges++;
                    Console.Write(" {0} generated...", Path.GetFileName(args[0]));
                }

                var languageDeserializerContent = Nikse.SubtitleEdit.Logic.LanguageDeserializerGenerator.GenerateCSharpXmlDeserializerForLanguage();
                var oldLanguageDeserializerContent = string.Empty;
                if (File.Exists(args[1]))
                    oldLanguageDeserializerContent = File.ReadAllText(args[1]);
                if (oldLanguageDeserializerContent != languageDeserializerContent)
                {
                    File.WriteAllText(args[1], languageDeserializerContent, Encoding.UTF8);
                    noOfChanges++;
                    Console.Write(" {0} generated...", Path.GetFileName(args[1]));
                }

                if (noOfChanges == 0)
                {
                    Console.WriteLine(" no changes");
                }
                else
                {
                    Console.WriteLine();
                }

                return 0;
            }
            catch (Exception exception)
            {
                Console.WriteLine();
                Console.WriteLine("ERROR: " + myName + ": " + exception.Message + Environment.NewLine + exception.StackTrace);

                return 2;
            }
        }
示例#3
0
        private static int Main(string[] args)
        {
            var myName = Environment.GetCommandLineArgs()[0];

            myName = Path.GetFileNameWithoutExtension(string.IsNullOrWhiteSpace(myName) ? System.Reflection.Assembly.GetEntryAssembly().Location : myName);
            if (args.Length != 2)
            {
                Console.Write("Usage: " + myName + @" <LanguageMaster> <LanguageDeserializer>
  <LanguageMaster>       Path to the LanguageMaster xml file (LanguageMaster.xml)
  <LanguageDeserializer> Path to the LanguageDeserializer source code file (LanguageDeserializer.cs)
");
                return(1);
            }

            Console.Write(WorkInProgress);

            try
            {
                int noOfChanges = 0;

                var language = new Nikse.SubtitleEdit.Core.Language {
                    General = { Version = FindVersionNumber() }
                };
                var languageAsXml    = language.GetCurrentLanguageAsXml();
                var oldLanguageAsXml = string.Empty;
                if (File.Exists(args[0]))
                {
                    oldLanguageAsXml = File.ReadAllText(args[0]);
                }

                if (oldLanguageAsXml != languageAsXml)
                {
                    language.Save(args[0]);
                    noOfChanges++;
                    Console.Write(" {0} generated...", Path.GetFileName(args[0]));
                }

                var languageDeserializerContent    = Nikse.SubtitleEdit.Logic.LanguageDeserializerGenerator.GenerateCSharpXmlDeserializerForLanguage();
                var oldLanguageDeserializerContent = string.Empty;
                if (File.Exists(args[1]))
                {
                    oldLanguageDeserializerContent = File.ReadAllText(args[1]);
                }

                if (oldLanguageDeserializerContent != languageDeserializerContent)
                {
                    File.WriteAllText(args[1], languageDeserializerContent, Encoding.UTF8);
                    noOfChanges++;
                    Console.Write(" {0} generated...", Path.GetFileName(args[1]));
                }

                if (noOfChanges == 0)
                {
                    Console.WriteLine(" no changes");
                }
                else
                {
                    Console.WriteLine();
                }

                return(0);
            }
            catch (Exception exception)
            {
                Console.WriteLine();
                Console.WriteLine("ERROR: " + myName + ": " + exception.Message + Environment.NewLine + exception.StackTrace);

                return(2);
            }
        }