예제 #1
0
        public async Task NotifyDeleted(NodeInstance node)
        {
            await ExecuteAction(node, _ => _?.OnDelete(node));

            var driverNode = _mapper.Get(node.ObjId);

            if (driverNode == null)
            {
                return;
            }
            foreach (var child in driverNode.Children)
            {
                await NotifyDeleted(child.DriverContext.NodeInstance);
            }

            await driverNode.Stop();

            _mapper.Remove(driverNode);
        }
예제 #2
0
        private Task <T> ExecuteAction <T>(NodeInstance node, Func <IDriverNode, Task <T> > action)
        {
            try
            {
                var driverNode = _mapper.Get(node.ObjId);
                if (driverNode != null)
                {
                    return(action(driverNode));
                }

                return(Task.FromResult(default(T)));
            }
            catch (NodeNotFoundException)
            {
                throw;
            }
            catch (Exception e)
            {
                _logger.LogError($"Could not execute action {action} {e}");
                throw;
            }
        }