示例#1
0
        /// <summary>
        /// Runs the compiler from the command line.
        /// </summary>
        /// <param name="arguments">The command line arguments. Each compiler defines its own.</param>
        /// <returns>0 for success, non-0 for error.</returns>
        private static int Main(string[] arguments)
        {
            CompilerOptions options = new CompilerOptions();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(arguments, options))
            {
                return 1;
            }

            var tzdbCompiler = new TzdbZoneInfoCompiler();
            var tzdb = tzdbCompiler.Compile(options.SourceDirectoryName);
            tzdb.LogCounts();
            if (options.ZoneId != null)
            {
                tzdb.GenerateDateTimeZone(options.ZoneId);
                return 0;
            }
            var windowsZones = CldrWindowsZonesParser.Parse(options.WindowsMappingFile);
            LogWindowsZonesSummary(windowsZones);
            var writer = CreateWriter(options);
            writer.Write(tzdb, windowsZones);

            if (options.OutputFileName != null)
            {
                Console.WriteLine("Reading generated data and validating...");
                var source = Read(options);
                source.Validate();
                if (options.TextDumpFile != null)
                {
                    CreateTextDump(source, options.TextDumpFile);
                }
            }
            return 0;
        }
示例#2
0
 private static TzdbDateTimeZoneSource LoadSource(string source)
 {
     if (source == null)
     {
         return TzdbDateTimeZoneSource.Default;
     }
     if (source.EndsWith(".nzd"))
     {
         var data = LoadFileOrUrl(source);
         return TzdbDateTimeZoneSource.FromStream(new MemoryStream(data));
     }
     else
     {
         var compiler = new TzdbZoneInfoCompiler(log: null);
         var database = compiler.Compile(source);
         return database.ToTzdbDateTimeZoneSource();
     }
 }
示例#3
0
        /// <summary>
        /// Runs the compiler from the command line.
        /// </summary>
        /// <param name="arguments">The command line arguments. Each compiler defines its own.</param>
        /// <returns>0 for success, non-0 for error.</returns>
        private static int Main(string[] arguments)
        {
            CompilerOptions options = new CompilerOptions();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(arguments, options))
            {
                return 1;
            }

            var tzdbCompiler = new TzdbZoneInfoCompiler();
            var tzdb = tzdbCompiler.Compile(options.SourceDirectoryName);
            tzdb.LogCounts();
            if (options.ZoneId != null)
            {
                tzdb.GenerateDateTimeZone(options.ZoneId);
                return 0;
            }
            var windowsZones = LoadWindowsZones(options, tzdb.Version);
            if (options.WindowsOverride != null)
            {
                var overrideFile = CldrWindowsZonesParser.Parse(options.WindowsOverride);
                windowsZones = MergeWindowsZones(windowsZones, overrideFile);
            }
            LogWindowsZonesSummary(windowsZones);
            var writer = new TzdbStreamWriter();
            using (var stream = CreateOutputStream(options))
            {
                writer.Write(tzdb, windowsZones, PclSupport.StandardNameToIdMap, stream);
            }

            if (options.OutputFileName != null)
            {
                Console.WriteLine("Reading generated data and validating...");
                var source = Read(options);
                source.Validate();
            }
            return 0;
        }
示例#4
0
 private static List<DateTimeZone> LoadSource(Options options)
 {
     var source = options.Source;
     if (source == null)
     {
         var provider = DateTimeZoneProviders.Tzdb;
         return provider.Ids.Select(id => provider[id]).ToList();
     }
     if (source.EndsWith(".nzd"))
     {
         var data = LoadFileOrUrl(source);
         var tzdbSource = TzdbDateTimeZoneSource.FromStream(new MemoryStream(data));
         return tzdbSource.GetIds().Select(id => tzdbSource.ForId(id)).ToList();
     }
     else
     {
         var compiler = new TzdbZoneInfoCompiler(log: null);
         var database = compiler.Compile(source);
         return database.GenerateDateTimeZones()
             .Concat(database.Aliases.Keys.Select(database.GenerateDateTimeZone))
             .ToList();
     }
 }