/// <summary> /// Returns the resource data for the required resource as a word list. If the stored /// resource is not a word list, an exception will be thrown. /// </summary> /// <param name="accessor">The resource data accessor to use to retrieve the data</param> /// <param name="culture">The culture to obtain the resource for</param> /// <param name="t">The type of the language resource to retrieve</param> /// <param name="fallback">Whether or not to use a fallback stragegy if specific /// resources cannot be found (see <see cref="IResourceDataAccessor.ReadResourceData"/>)</param> /// <returns>The requested data as a word list</returns> public static Core.Wordlist LoadWordlist(IResourceDataAccessor accessor, System.Globalization.CultureInfo culture, LanguageResourceType t, bool fallback) { // TODO check resource type and load only compatible data using (System.IO.Stream s = accessor.ReadResourceData(culture, t, fallback)) { if (s == null) { return(null); } Core.Wordlist l = new Core.Wordlist(); l.Load(s); return(l); } }
public LanguageResources(System.Globalization.CultureInfo culture, IResourceDataAccessor accessor) { if (culture == null) { throw new ArgumentNullException("culture"); } if (accessor == null) { accessor = Configuration.Load(); } _Culture = culture; _Accessor = accessor; // TODO if we have a DB-based resource accessor, we don't want individual roundtrips to the DB to // query the status for each resource. Rather the accessor should return all status in one call. // TODO this class intentionally implements a resource cache. We need however a protocol which // detects changes to the resource storage and updates the cache. _AbbreviationsStatus = _Accessor.GetResourceStatus(culture, LanguageResourceType.Abbreviations, true); _StopwordsStatus = _Accessor.GetResourceStatus(culture, LanguageResourceType.Stopwords, true); _StemmingRulesStatus = _Accessor.GetResourceStatus(culture, LanguageResourceType.StemmingRules, true); }
/// <summary> /// Adds the accessor to the list of individual accessors. The item will be added /// at the end of the accessor list, giving it lower priority than the preceding items. /// </summary> /// <param name="racc">The accessor to add.</param> public void Add(IResourceDataAccessor racc) { _IndividualAccessors.Add(racc); }
/// <summary> /// Inserts a new resource data accessor at the beginning of the list. /// </summary> /// <param name="racc">The accessor to add.</param> public void Insert(IResourceDataAccessor racc) { _IndividualAccessors.Insert(0, racc); }
/// <summary> /// Inserts a new resource data accessor at the specified position in the list of /// elements. /// </summary> /// <param name="index">The position at which to add the item.</param> /// <param name="racc">The accessor to add.</param> public void Insert(int index, IResourceDataAccessor racc) { _IndividualAccessors.Insert(index, racc); }