internal override Node RemoveChild(UpdateTreeCommand command) { if (!ImmutableInterlocked.TryRemove(ref children, command.Item.Id, out var child)) { return(null); } child.pipeline?.OnRemoved(root, this, child, command); return(child); //root.log.LogDebug("Tree: RemoveChild spent {TreeTicks} ticks in tree and {PipelineTicks} in pipeline.", t1, watch.Elapsed.Ticks - t1); }
internal override void AddChild(UpdateTreeCommand command, Node newNode) { //ImmutableInterlocked.AddOrUpdate(ref children, command.Item.Id, _ => newNode, (k,v) => newNode); if (ImmutableInterlocked.TryAdd(ref children, command.Item.Id, newNode)) { newNode.SetParent(this); newNode.pipeline?.OnAdded(root, this, newNode, command); return; } //root.log.LogDebug("Tree: AddChild spent {TreeTicks} ticks in tree and {PipelineTicks} in pipeline.", t1, watch.Elapsed.Ticks - t1); if (root is SystemTree && command.Action == ETreeAction.Add && command.NodeType == ENodeType.Market) { root.log.LogDebug("Tree: AddChild failed due to market already in child collection!"); } }
public RecordersViewModel(NamingServiceManager manager) { _manager = manager; _recorders = new ObservableCollection <Recorder>(); RecorderViewModels = ViewModelHelper.CreateReadOnlyDispatcherCollection <RecorderControlViewModel, Recorder>( _recorders, recorder => new RecorderControlViewModel(this, recorder), DispatcherHelper.UIDispatcher); NamingServiceTree = ViewModelHelper.CreateReadOnlyDispatcherCollection <TreeViewItemViewModel, TreeViewItemViewModel>( _manager.OutPortTree, item => item, DispatcherHelper.UIDispatcher); // NamingServiceManagerのIsUpdatingの状態が変わったら、UpdateTreeCommandの有効無効を切り替える Observable.FromEventPattern <PropertyChangedEventArgs>(_manager, "PropertyChanged") .Where(e => e.EventArgs.PropertyName == "IsUpdating") .Subscribe(_ => UpdateTreeCommand.RaiseCanExecuteChanged()); }