/// <summary> /// Register a new break iterator of the indicated kind, to use in the given /// locale. Clones of the iterator will be returned if a request for a break /// iterator of the given kind matches or falls back to this locale. /// </summary> /// /// <param name="iter">the BreakIterator instance to adopt.</param> /// <param name="locale">the Locale for which this instance is to be registered</param> /// <param name="kind">the type of iterator for which this instance is to beregistered</param> /// <returns>a registry key that can be used to unregister this instance</returns> /// @stable ICU 3.2 public static Object RegisterInstance(BreakIterator iter, ULocale locale, int kind) { // If the registered object matches the one in the cache, then // flush the cached object. if (iterCache[kind] != null) { BreakIterator.BreakIteratorCache cache = (BreakIterator.BreakIteratorCache)iterCache[kind].Target; if (cache != null) { if (cache.GetLocale().Equals(locale)) { iterCache[kind] = null; } } } return(GetShim().RegisterInstance(iter, locale, kind)); }
// end of registration /// <exclude/> /// <summary> /// Get a particular kind of BreakIterator for a locale. Avoids writing a /// switch statement with getXYZInstance(where) calls. /// </summary> /// public static BreakIterator GetBreakInstance(ULocale where, int kind) { if (iterCache[kind] != null) { BreakIterator.BreakIteratorCache cache = (BreakIterator.BreakIteratorCache)iterCache[kind].Target; if (cache != null) { if (cache.GetLocale().Equals(where)) { return(cache.CreateBreakInstance()); } } } // sigh, all to avoid linking in ICULocaleData... BreakIterator result = GetShim().CreateBreakIterator(where, kind); BreakIterator.BreakIteratorCache cache_0 = new BreakIterator.BreakIteratorCache(where, result); iterCache[kind] = new WeakReference(cache_0); return(result); }