private static void Unregister(string groupName, RadioButton radioButton) { List<WeakReference> weakReferences; if (groupName == null) { groupName = ""; } if (RadioButton.groupNameToElements != null && RadioButton.groupNameToElements.TryGetValue(groupName, out weakReferences) && weakReferences != null) { RadioButton.PurgeExpiredReferences(weakReferences, radioButton); if (weakReferences.Count == 0) { RadioButton.groupNameToElements.Remove(groupName); } } }
private static void Register(string groupName, RadioButton radioButton) { if (groupName == null) { groupName = ""; } if (RadioButton.groupNameToElements == null) { RadioButton.groupNameToElements = new Dictionary<string, List<WeakReference>>(1); } List<WeakReference> weakReferences = null; if (!RadioButton.groupNameToElements.TryGetValue(groupName, out weakReferences) || weakReferences == null) { weakReferences = new List<WeakReference>(1); RadioButton.groupNameToElements[groupName] = weakReferences; } else { RadioButton.PurgeExpiredReferences(weakReferences, null); } weakReferences.Add(new WeakReference(radioButton)); }