internal PObjectContainerEventArgs(PObjectContainerAction action, string key, PObject oldItem, PObject newItem) { Action = action; Key = key; OldItem = oldItem; NewItem = newItem; }
protected void OnChildReplaced(string key, PObject oldChild, PObject newChild) { oldChild.Parent = null; newChild.Parent = this; OnCollectionChanged(PObjectContainerAction.Replaced, key, oldChild, newChild); }
public static IEnumerable <KeyValuePair <string, PObject> > ToEnumerable(PObject obj) { if (obj is PDictionary) { return((PDictionary)obj); } if (obj is PArray) { return(((PArray)obj).Select(k => new KeyValuePair <string, PObject>(k is IPValueObject ? ((IPValueObject)k).Value.ToString() : null, k))); } return(Enumerable.Empty <KeyValuePair <string, PObject> >()); }
public void Replace(PObject newObject) { var p = Parent; if (p is PDictionary dict) { var key = dict.GetKey(this); if (key == null) { return; } Remove(); dict[key] = newObject; } else if (p is PArray arr) { arr.Replace(this, newObject); } }
protected void OnCollectionChanged(PObjectContainerAction action, string key, PObject oldChild, PObject newChild) { if (SuppressChangeEvents) { return; } CollectionChanged?.Invoke(this, new PObjectContainerEventArgs(action, key, oldChild, newChild)); OnChanged(EventArgs.Empty); if (Parent != null) { Parent.OnCollectionChanged(Key, this); } }
protected void OnChildRemoved(string key, PObject child) { child.Parent = null; OnCollectionChanged(PObjectContainerAction.Removed, key, child, null); }
internal void OnCollectionChanged(string key, PObject child) { OnCollectionChanged(PObjectContainerAction.Changed, key, null, child); }
protected void OnChildAdded(string key, PObject child) { child.Parent = this; OnCollectionChanged(PObjectContainerAction.Added, key, null, child); }