public virtual Object Create(IBM.ICU.Impl.ICUService.Key key, ICUService serviceArg) { if (key.CurrentID().Equals(greetingID)) { Object previous = serviceArg.GetKey(key, null, this); return("A different greeting: \"" + previous + "\""); } return(null); }
protected internal override Object HandleDefault(IBM.ICU.Impl.ICUService.Key key, String[] actualIDReturn) { if (actualIDReturn != null) { actualIDReturn[0] = "root"; } try { return(new RuleBasedCollator(IBM.ICU.Util.ULocale.ROOT)); } catch (MissingManifestResourceException e) { return(null); } }
public override Object Create(IBM.ICU.Impl.ICUService.Key key, ICUService service) { if (HandlesKey(key)) { IBM.ICU.Impl.ICULocaleService.LocaleKey lkey = (IBM.ICU.Impl.ICULocaleService.LocaleKey)key; ULocale loc = lkey.CanonicalLocale(); Object result = delegat0.CreateCalendar(loc); if (result == null) { result = service.GetKey(key, null, this); } return(result); } return(null); }
public void TestCoverage() { // Key IBM.ICU.Impl.ICUService.Key key = new IBM.ICU.Impl.ICUService.Key("foobar"); Logln("ID: " + key.Id()); Logln("canonicalID: " + key.CanonicalID()); Logln("currentID: " + key.CurrentID()); Logln("has fallback: " + key.Fallback()); // SimpleFactory Object obj = new Object(); IBM.ICU.Impl.ICUService.SimpleFactory sf = new IBM.ICU.Impl.ICUService.SimpleFactory(obj, "object"); try { sf = new IBM.ICU.Impl.ICUService.SimpleFactory(null, null); Errln("didn't throw exception"); } catch (ArgumentException e) { Logln("OK: " + e.Message); } catch (Exception e_0) { Errln("threw wrong exception" + e_0); } Logln(sf.GetDisplayName("object", null)); // ICUService ICUService service = new ICUService(); service.RegisterFactory(sf); try { service.Get(null, null); Errln("didn't throw exception"); } catch (NullReferenceException e_1) { Logln("OK: " + e_1.Message); } /* * catch (Exception e) { errln("threw wrong exception" + e); } */ try { service.RegisterFactory(null); Errln("didn't throw exception"); } catch (NullReferenceException e_2) { Logln("OK: " + e_2.Message); } catch (Exception e_3) { Errln("threw wrong exception" + e_3); } try { service.UnregisterFactory(null); Errln("didn't throw exception"); } catch (NullReferenceException e_4) { Logln("OK: " + e_4.Message); } catch (Exception e_5) { Errln("threw wrong exception" + e_5); } Logln("object is: " + service.Get("object")); Logln("stats: " + service.Stats()); // ICURWLock ICURWLock rwlock = new ICURWLock(); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); Logln("stats: " + rwlock.ClearStats()); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); try { rwlock.ReleaseRead(); Errln("no error thrown"); } catch (InvalidOperationException e_6) { Logln("OK: " + e_6.Message); } try { rwlock.ReleaseWrite(); Errln("no error thrown"); } catch (InvalidOperationException e_7) { Logln("OK: " + e_7.Message); } // ICULocaleService // LocaleKey // LocaleKey lkey = LocaleKey.create("en_US", "ja_JP"); // lkey = LocaleKey.create(null, null); IBM.ICU.Impl.ICULocaleService.LocaleKey lkey = IBM.ICU.Impl.ICULocaleService.LocaleKey .CreateWithCanonicalFallback("en_US", "ja_JP"); Logln("lkey: " + lkey); lkey = IBM.ICU.Impl.ICULocaleService.LocaleKey.CreateWithCanonicalFallback(null, null); Logln("lkey from null,null: " + lkey); // LocaleKeyFactory IBM.ICU.Impl.ICULocaleService.LocaleKeyFactory lkf = new ICUServiceTest.LKFSubclass(false); Logln("lkf: " + lkf); Logln("obj: " + lkf.Create(lkey, null)); Logln(lkf.GetDisplayName("foo", null)); Logln(lkf.GetDisplayName("bar", null)); lkf.UpdateVisibleIDs(new Hashtable()); IBM.ICU.Impl.ICULocaleService.LocaleKeyFactory invisibleLKF = new ICUServiceTest.LKFSubclass(false); Logln("obj: " + invisibleLKF.Create(lkey, null)); Logln(invisibleLKF.GetDisplayName("foo", null)); Logln(invisibleLKF.GetDisplayName("bar", null)); invisibleLKF.UpdateVisibleIDs(new Hashtable()); // ResourceBundleFactory IBM.ICU.Impl.ICULocaleService.ICUResourceBundleFactory rbf = new IBM.ICU.Impl.ICULocaleService.ICUResourceBundleFactory(); Logln("RB: " + rbf.Create(lkey, null)); // ICUNotifier ICUNotifier nf = new ICUServiceTest.ICUNSubclass(); try { nf.AddListener(null); Errln("added null listener"); } catch (NullReferenceException e_8) { Logln(e_8.Message); } catch (Exception e_9) { Errln("got wrong exception"); } try { nf.AddListener(new ICUServiceTest.WrongListener()); Errln("added wrong listener"); } catch (InvalidOperationException e_10) { Logln(e_10.Message); } catch (Exception e_11) { Errln("got wrong exception"); } try { nf.RemoveListener(null); Errln("removed null listener"); } catch (NullReferenceException e_12) { Logln(e_12.Message); } catch (Exception e_13) { Errln("got wrong exception"); } nf.RemoveListener(new ICUServiceTest.MyListener()); nf.NotifyChanged(); nf.AddListener(new ICUServiceTest.MyListener()); nf.RemoveListener(new ICUServiceTest.MyListener()); }
public Object Create(IBM.ICU.Impl.ICUService.Key key, ICUService unusedService) { return(new ULocale(key.CurrentID())); }