/// <summary> /// Attempts to load the FSTs from the resource accessor. /// </summary> private List <CalendarDateTimePatterns> LoadPatterns(Core.Tokenization.DateTimePatternType types, bool allCalendars) { if (_Accessor == null) { return(null); } DateTimePatternType[] iter = new DateTimePatternType[] { DateTimePatternType.LongDate, DateTimePatternType.ShortDate, DateTimePatternType.LongTime, DateTimePatternType.ShortTime }; List <CalendarDateTimePatterns> result = null; // we currently only support one culture pattern CalendarDateTimePatterns thePattern = null; foreach (DateTimePatternType t in iter) { if ((types & t) == 0) { continue; } Core.Resources.LanguageResourceType rt = Core.Resources.LanguageResourceType.Undefined; switch (t) { case DateTimePatternType.LongDate: rt = Core.Resources.LanguageResourceType.LongDateFST; break; case DateTimePatternType.ShortDate: rt = Core.Resources.LanguageResourceType.ShortDateFST; break; case DateTimePatternType.ShortTime: rt = Core.Resources.LanguageResourceType.ShortTimeFST; break; case DateTimePatternType.LongTime: rt = Core.Resources.LanguageResourceType.LongTimeFST; break; default: throw new Exception("Cannot map token type to corresponding resource type"); } if (_Accessor.GetResourceStatus(_Culture, rt, false) != Core.Resources.ResourceStatus.NotAvailable) { byte[] data = _Accessor.GetResourceData(_Culture, rt, false); LanguagePlatform.Lingua.FST.FST fst = LanguagePlatform.Lingua.FST.FST.Create(data); if (thePattern == null) { // TODO support the case where some (not all) FSTs are loaded from the resources result = new List <CalendarDateTimePatterns>(); // TODO support all calendars thePattern = new CalendarDateTimePatterns(_Culture, null); result.Add(thePattern); } // TODO compute FIRST() for the FST at load time (or persistently store it?) thePattern.Patterns.Add(new DateTimePattern(t, _Culture, "(unavailable)", fst)); } } return(result); }
private Wordlist LoadWordlist(Core.Resources.LanguageResourceType t) { return(ResourceStorage.LoadWordlist(_Accessor, Culture, t, true)); }