コード例 #1
0
        public virtual bool TryResetChild(IExecutableStep child, string rootId = null)
        {
            if (child.Root != null)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(rootId))
            {
                if (rootId == Id)
                {
                    return(ResetChild(child));
                }

                var rootStep = FindExecutableStepById(rootId);
                if (rootStep != null)
                {
                    return(rootStep.TryResetChild(child, rootId));
                }

                return(false);
            }

            var root = FindExecutableStepById(child.Id)?.Root;

            if (root != null)
            {
                return(root.TryResetChild(child, root.Id));
            }

            return(false);
        }
コード例 #2
0
        public bool TryAddChild(IExecutableStep child, string rootId = null)
        {
            if (child == null)
            {
                return(false);
            }

            if (child.Root != null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(rootId))
            {
                return(AddChild(child));
            }

            if (rootId == Id)
            {
                return(AddChild(child));
            }

            var root = FindExecutableStepById(rootId);

            if (root != null)
            {
                return(root.TryAddChild(child));
            }

            return(false);
        }
コード例 #3
0
        private UserControl ShowStepUserControl(IExecutableStep step)
        {
            if (step == null)
            {
                return(null);
            }

            var type = step.GetType().FullName;

            return(stepControls[type]);
        }
コード例 #4
0
 private bool AddChild(IExecutableStep child)
 {
     if (CheckAllChildsIsNotRecource(child))
     {
         _childs.Add(child);
         child.Root = this;
         //OnPropertyChanged(nameof(Childs));
         return(true);
     }
     return(false);
 }
コード例 #5
0
        private bool ResetChild(IExecutableStep child)
        {
            if (CheckAllChildsIsNotRecource(child))
            {
                for (var i = 0; i < _childs.Count; i++)
                {
                    if (child.Id == _childs[i].Id)
                    {
                        _childs[i] = child;
                        child.Root = this;
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #6
0
        public bool TryRemoveChild(IExecutableStep child)
        {
            if (child?.Root == null)
            {
                return(false);
            }

            if (_childs.Contains(child))
            {
                _childs.Remove(child);
                //OnPropertyChanged(nameof(Childs));
                return(true);
            }

            var step = FindExecutableStepById(child.Root.Id);

            return(step.TryRemoveChild(child));
        }
コード例 #7
0
        public virtual IExecutableStep TryGetStepById(string id)
        {
            IExecutableStep step = null;

            if (id == Id)
            {
                step = this;
            }
            else
            {
                foreach (var child in Childs)
                {
                    step = child.TryGetStepById(id);
                    if (step != null)
                    {
                        break;
                    }
                }
            }
            return(step);
        }
コード例 #8
0
 private bool CheckAllChildsIsNotRecource(IExecutableStep child)
 {
     return(child.FindExecutableStepById(Id) == null);
 }