internal static void RegisterProperty(TranslatedProperty translatedProperty) { lock (propertiesLocker) { bool add = true; var toRemove = new List <WeakReference>(); foreach (var item in properties) { if (!item.IsAlive) { toRemove.Add(item); } else if (item.Target == translatedProperty) { add = false; } } foreach (var item in toRemove) { properties.Remove(item); } if (add) { properties.Add(new WeakReference(translatedProperty)); } } }
internal static void UnregisterProperty(TranslatedProperty translatedProperty) { lock (propertiesLocker) { var reference = properties.Where(p => p.Target == translatedProperty).FirstOrDefault(); if (reference != null) { properties.Remove(reference); } } }