private void btnBuild_Click(object sender, EventArgs e) { if (!IsCldrPath(tbxCldrPath.Text)) { MessageBox.Show("The CLDR path does not contain any CLDR files"); } else if (!Directory.Exists(tbxNCldrPath.Text)) { MessageBox.Show("The NCLDR output path does not exist"); } else { previousSection = null; INCldrFileDataSource ncldrFileDataSource = this.GetNewNCldrDataSource(); ncldrFileDataSource.NCldrDataPath = tbxNCldrPath.Text; if (!ncldrFileDataSource.Exists() || MessageBox.Show("The NCLDR data file exists - overwrite it ?", "NCLDR Builder", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { tbxProgress.Text = String.Empty; NCldrBuilder.Build( tbxCldrPath.Text, ncldrFileDataSource, new NCldrBuilderProgressEventHandler(Progress), this.options); Progress("Done."); } } }
/// <summary> /// GetDataSourcesFromAssembly gets an array of INCldrFileDataSource objects from a given assembly /// </summary> /// <param name="assemblyFilename">The filename of the assembly</param> /// <returns>An array of INCldrFileDataSource objects</returns> private static INCldrFileDataSource[] GetDataSourcesFromAssembly(string assemblyFilename) { Assembly assembly; try { assembly = Assembly.LoadFrom(assemblyFilename); } catch (FileLoadException) { return(null); } Type[] ncldrDataSourceTypes = (from t in assembly.GetTypes() where typeof(INCldrFileDataSource).IsAssignableFrom(t) select t).ToArray(); if (ncldrDataSourceTypes == null || ncldrDataSourceTypes.Length == 0) { return(null); } List <INCldrFileDataSource> dataSources = new List <INCldrFileDataSource>(); foreach (Type ncldrDataSourceType in ncldrDataSourceTypes) { INCldrFileDataSource dataSource = (INCldrFileDataSource)Activator.CreateInstance(ncldrDataSourceType); dataSources.Add(dataSource); } return(dataSources.ToArray()); }
public static void Build( string cldrPath, INCldrFileDataSource dataSource, NCldrBuilderProgressEventHandler progress = null, NCldrBuilderOptions options = null) { NCldrBuilder.options = options; NCldrBuilder.progress = progress; NCldrBuilder.cldrPath = cldrPath; NCldrBuilder.ncldrDataSource = dataSource; supplementalDataDocument = GetXmlDocument(@"common\supplemental\supplementalData.xml"); NCldrData ncldrData = new NCldrData(); ncldrData.CultureNames = GetCultureNames(); ncldrData.CultureDatas = GetCultures(); ncldrData.CalendarPreferences = GetCalendarPreferences(); ncldrData.CalendarTypes = GetCalendarTypes(); ncldrData.CharacterFallbacks = GetCharacterFallbacks(); ncldrData.Currencies = GetDescriptions <Currency>("currency", "cu", "currency"); ncldrData.CurrencyFractions = GetCurrencyFractions(); ncldrData.DayPeriodRuleSets = GetDayPeriodRuleSets(); ncldrData.GenderLists = GetGenderLists(); ncldrData.LanguageMatches = GetLanguageMatches(); ncldrData.LikelySubTags = GetLikelySubTags(); ncldrData.MeasurementData = GetMeasurementData(); ncldrData.MetaTimeZones = GetMetaTimeZones(); ncldrData.NumberingSystems = GetNumberingSystems(); ncldrData.OrdinalRuleSets = GetPluralRuleSets(true); ncldrData.ParentCultures = GetParentCultures(); ncldrData.PluralRuleSets = GetPluralRuleSets(false); ncldrData.PostcodeRegexes = GetPostcodeRegexes(); ncldrData.References = GetReferences(); ncldrData.RegionCodes = GetRegionCodes(); ncldrData.RegionGroups = GetRegionGroups(); ncldrData.RegionInformations = GetRegionInformations(); ncldrData.RegionTelephoneCodes = GetRegionTelephoneCodes(); ncldrData.TimeData = GetTimeData(); ncldrData.TimeZones = GetTimeZones(); ncldrData.WeekData = GetWeekData(); ncldrData.WindowsMetaTimeZones = GetWindowsMetaTimeZones(); Build(ncldrData); }
public static void Build( string cldrPath, INCldrFileDataSource dataSource, NCldrBuilderProgressEventHandler progress = null, NCldrBuilderOptions options = null) { NCldrBuilder.options = options; NCldrBuilder.progress = progress; NCldrBuilder.cldrPath = cldrPath; NCldrBuilder.ncldrDataSource = dataSource; supplementalDataDocument = GetXmlDocument(@"common\supplemental\supplementalData.xml"); NCldrData ncldrData = new NCldrData(); ncldrData.CultureNames = GetCultureNames(); ncldrData.CultureDatas = GetCultures(); ncldrData.CalendarPreferences = GetCalendarPreferences(); ncldrData.CalendarTypes = GetCalendarTypes(); ncldrData.CharacterFallbacks = GetCharacterFallbacks(); ncldrData.Currencies = GetDescriptions<Currency>("currency", "cu", "currency"); ncldrData.CurrencyFractions = GetCurrencyFractions(); ncldrData.DayPeriodRuleSets = GetDayPeriodRuleSets(); ncldrData.GenderLists = GetGenderLists(); ncldrData.LanguageMatches = GetLanguageMatches(); ncldrData.LikelySubTags = GetLikelySubTags(); ncldrData.MeasurementData = GetMeasurementData(); ncldrData.MetaTimeZones = GetMetaTimeZones(); ncldrData.NumberingSystems = GetNumberingSystems(); ncldrData.OrdinalRuleSets = GetPluralRuleSets(true); ncldrData.ParentCultures = GetParentCultures(); ncldrData.PluralRuleSets = GetPluralRuleSets(false); ncldrData.PostcodeRegexes = GetPostcodeRegexes(); ncldrData.References = GetReferences(); ncldrData.RegionCodes = GetRegionCodes(); ncldrData.RegionGroups = GetRegionGroups(); ncldrData.RegionInformations = GetRegionInformations(); ncldrData.RegionTelephoneCodes = GetRegionTelephoneCodes(); ncldrData.TimeData = GetTimeData(); ncldrData.TimeZones = GetTimeZones(); ncldrData.WeekData = GetWeekData(); ncldrData.WindowsMetaTimeZones = GetWindowsMetaTimeZones(); Build(ncldrData); }
static void Main(string[] args) { Console.WriteLine("NCLDR Builder"); Console.WriteLine("NCLDR Builder builds the NCLDR data file from CLDR data"); Console.WriteLine(String.Empty); CommandArgumentsReader reader = new CommandArgumentsReader(args); string cldrPath = reader.GetArgumentValue("-CLDRPath"); string ncldrPath = reader.GetArgumentValue("-NCLDRPath"); displayMode = GetDisplayMode(reader.GetArgumentValue("-DisplayMode")); string dataSourceName = reader.GetArgumentValue("-DataSource"); NCldrDataSources.Discover(); INCldrFileDataSource dataSource = GetDataSource(dataSourceName); if (String.IsNullOrEmpty(cldrPath) || String.IsNullOrEmpty(ncldrPath) || dataSource == null) { Console.WriteLine("Syntax:"); Console.WriteLine("NCldrBuilderCmd -CLDRPath:<CLDRPath> -NCLDRPath:<NCLDRPath> [-DisplayMode:Quiet|Verbose|Diagnostics] [-DataSource:Binary|Json]"); Console.WriteLine("where:"); Console.WriteLine(@"<CLDRPath> is the path to the CLDR root folder e.g. C:\CLDR\Release23"); Console.WriteLine(@"<NCLDRPath> is the path to the NCLDR output folder e.g. C:\Projects\NCldr\Source\NCldr\NCldrData"); Console.WriteLine(@"DisplayMode is either Quiet, Verbose or Diagnostics indicating the volume of progress information displayed"); Console.WriteLine(@"DataSource is either Binary (default), Json or XML indicating the file format of the data file created"); } else if (!Directory.Exists(cldrPath)) { Console.WriteLine(String.Format("CLDRPath '{0}' does not exist", cldrPath)); } else if (!Directory.Exists(ncldrPath)) { Console.WriteLine(String.Format("NCLDRPath '{0}' does not exist", ncldrPath)); } else { dataSource.NCldrDataPath = ncldrPath; Console.WriteLine(String.Empty); NCldrBuilder.Build(cldrPath, dataSource, new NCldrBuilderProgressEventHandler(Progress)); Console.WriteLine(String.Empty); Console.WriteLine("Done."); } }