public void WeakKeyDictionary_AddEntry_ContainsKeyAsObjectSucceeds() { using (var key = new DisposableTestObject("Shemp")) { const int FortyTwo = 42; var dictionary = new WeakKeyDictionary <DisposableTestObject, int>(); Assert.True(dictionary.AddEntry(key, FortyTwo)); Assert.True(dictionary.Contains((object)key)); } }
public void WeakKeyDictionary_AddEntry_ContainsKeyValuePairFails() { using (var key = new DisposableTestObject("Curly")) { const int FortyTwo = 42; var dictionary = new WeakKeyDictionary <DisposableTestObject, int>(); Assert.True(dictionary.AddEntry(key, FortyTwo)); Assert.False(dictionary.Contains(new KeyValuePair <DisposableTestObject, int>(key, -3))); } }
public static string TranslateText(string input, object obj) { if (DynamicTranslator.IsPastingToClipboard.Value) { GUIUtility.systemCopyBuffer = input; } if (string.IsNullOrEmpty(input)) { return(input); } if (obj != null && !OriginalTranslations.Contains(obj)) { OriginalTranslations.Set(obj, input); } if (Translations.TryGetValue(input.Trim(), out CompiledLine translation)) { return(translation.TranslatedLine); } if (TryGetRegex(input, out string regexTranslation)) { return(regexTranslation); } if (obj is UnityEngine.UI.Text) { var immediatelyTranslated = DynamicTranslator.OnOnUnableToTranslateUgui(obj, input); if (immediatelyTranslated != null) { return(immediatelyTranslated); } } else if (obj is TMP_Text) { var immediatelyTranslated = DynamicTranslator.OnOnUnableToTranslateTextMeshPro(obj, input); if (immediatelyTranslated != null) { return(immediatelyTranslated); } } if (!Untranslated.Contains(input)) { Untranslated.Add(input); } return(input); }