public override void Dispose() { if (_resources != null) { foreach (object res in _resources.Values) { // Really dispose objects if we are the owner MPF.CleanupAndDisposeResourceIfOwner(res, this); } } base.Dispose(); }
public void Clear() { if (_resources == null) { return; } foreach (KeyValuePair <object, object> kvp in _resources) { MPF.CleanupAndDisposeResourceIfOwner(kvp.Value, this); } _resources = null; FireChanged(); }
internal void Set(object key, object value, bool fireChanged) { IDictionary <object, object> resources = GetOrCreateUnderlayingDictionary(); object oldRes; if (resources.TryGetValue(key, out oldRes)) { MPF.CleanupAndDisposeResourceIfOwner(oldRes, this); } resources[key] = value; MPF.SetOwner(value, this, false); if (fireChanged) { FireChanged(); } }
public bool Remove(KeyValuePair <object, object> item) { if (_resources == null) { return(false); } object oldRes; if (_resources.TryGetValue(item.Key, out oldRes)) { MPF.CleanupAndDisposeResourceIfOwner(oldRes, this); } bool result = _resources.Remove(item); FireChanged(); return(result); }
internal bool Remove(object key, bool fireChanged) { if (_resources == null) { return(false); } object oldRes; if (_resources.TryGetValue(key, out oldRes)) { MPF.CleanupAndDisposeResourceIfOwner(oldRes, this); } bool result = _resources.Remove(key); if (fireChanged) { FireChanged(); } return(result); }
public void RemoveResources(ResourceDictionary dict) { if (_resources == null) { return; } bool wasChanged = false; foreach (object key in dict.Keys) { object oldObj; if (_resources.TryGetValue(key, out oldObj)) { MPF.CleanupAndDisposeResourceIfOwner(oldObj, this); _resources.Remove(key); wasChanged = true; } } if (wasChanged) { FireChanged(); } }
void OnValueChanged(AbstractProperty prop, object oldVal) { MPF.CleanupAndDisposeResourceIfOwner(oldVal, this); MPF.SetOwner(Value, this, false); }
public override void Dispose() { MPF.CleanupAndDisposeResourceIfOwner(Value, this); base.Dispose(); }