예제 #1
0
        private void Initialize(bool isUpdating)
        {
            var path = ModelNodePath.GetPath(((ObservableModelNode)Root).sourceNode, targetNode);

            if (!path.IsValid)
            {
                throw new InvalidOperationException("Unable to retrieve the path of the given model node.");
            }

            foreach (var command in targetNode.Commands)
            {
                var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, Path, Owner.Identifier, path, Owner.ModelContainer, Owner.GetDirtiableViewModels(this));
                AddCommand(commandWrapper);
            }

            if (!isPrimitive)
            {
                GenerateChildren(targetNode, isUpdating);
            }

            isInitialized = true;

            if (Owner.ObservableViewModelService != null)
            {
                var data = Owner.ObservableViewModelService.RequestAssociatedData(this, isUpdating);
                SetValue(ref associatedData, data, "AssociatedData");
            }

            CheckDynamicMemberConsistency();
        }
예제 #2
0
        internal protected virtual void Initialize()
        {
            var targetNode     = GetTargetNode(SourceNode, Index);
            var targetNodePath = SourceNodePath.GetChildPath(SourceNode, targetNode);

            if (targetNodePath == null || !targetNodePath.IsValid)
            {
                throw new InvalidOperationException("Unable to retrieve the path of the given model node.");
            }

            var commandPath = targetNodePath;

            if ((!SourceNode.Content.ShouldProcessReference || targetNode == SourceNode || targetNode == null) && !Index.IsEmpty)
            {
                // When the references are not processed or when the value is null, there is no actual target node.
                // However, the commands need the index to be able to properly set the modified value
                commandPath = targetNodePath.PushElement(Index, GraphNodePath.ElementType.Index);
            }

            if (targetNode != SourceNode && targetNode != null)
            {
                foreach (var command in targetNode.Commands)
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, commandPath);
                    AddCommand(commandWrapper);
                }
            }

            var targetCommandNames = Commands.Select(x => x.Name).ToList();

            foreach (var command in SourceNode.Commands)
            {
                // Add source commands that are not already provided by the target node
                if (!targetCommandNames.Contains(command.Name))
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, commandPath);
                    AddCommand(commandWrapper);
                }
            }

            if (!isPrimitive && targetNode != null)
            {
                GenerateChildren(targetNode, targetNodePath);
            }

            isInitialized = true;

            Owner.ObservableViewModelService?.NotifyNodeInitialized(this);

            FinalizeChildrenInitialization();

            CheckDynamicMemberConsistency();
        }
        public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, IReadOnlyList<NodeCommandWrapperBase> commands)
            : base(serviceProvider)
        {
            if (commands == null) throw new ArgumentNullException(nameof(commands));
            if (commands.Count == 0) throw new ArgumentException(@"The collection of commands to combine is empty", nameof(commands));

            firstCommand = commands[0] as ModelNodeCommandWrapper;
            if (firstCommand != null && commands.OfType<ModelNodeCommandWrapper>().Any(x => !ReferenceEquals(x.NodeCommand, firstCommand.NodeCommand)))
                throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", nameof(commands));

            this.commands = commands;
            Name = name;
        }
예제 #4
0
        protected internal void Initialize()
        {
            var targetNode = GetTargetNode(SourceNode, Index);

            if (targetNode != SourceNode && targetNode != null)
            {
                foreach (var command in targetNode.Commands)
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, SourceNodePath, Index);
                    AddCommand(commandWrapper);
                }
            }

            var targetCommandNames = Commands.Select(x => x.Name).ToList();

            foreach (var command in SourceNode.Commands)
            {
                // Add source commands that are not already provided by the target node
                if (!targetCommandNames.Contains(command.Name))
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, SourceNodePath, Index);
                    AddCommand(commandWrapper);
                }
            }

            if (!isPrimitive && targetNode != null)
            {
                var targetNodePath = GetTargetNodePath();
                if (targetNodePath == null || !targetNodePath.IsValid)
                {
                    throw new InvalidOperationException("Unable to retrieve the path of the given model node.");
                }

                GenerateChildren(targetNode, targetNodePath);
            }

            isInitialized = true;

            Owner.ObservableViewModelService?.NotifyNodeInitialized(this);

            FinalizeChildrenInitialization();

            CheckDynamicMemberConsistency();
        }
예제 #5
0
        internal protected virtual void Initialize()
        {
            var targetNodePath = SourceNodePath.GetChildPath(SourceNode, targetNode);

            if (targetNodePath == null || !targetNodePath.IsValid)
            {
                throw new InvalidOperationException("Unable to retrieve the path of the given model node.");
            }

            if (!targetNode.Content.ShouldProcessReference && Index != null)
            {
                // When the references are not processed, there is no actual target node.
                // However, the commands need the index to be able to properly set the modified value
                targetNodePath = targetNodePath.PushElement(Index, ModelNodePath.ElementType.Index);
            }

            foreach (var command in targetNode.Commands)
            {
                var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, Path, Owner, targetNodePath, Owner.Dirtiables);
                AddCommand(commandWrapper);
            }

            if (!isPrimitive)
            {
                GenerateChildren(targetNode, targetNodePath);
            }

            isInitialized = true;

            if (Owner.ObservableViewModelService != null)
            {
                foreach (var key in AssociatedData.Keys.ToList())
                {
                    RemoveAssociatedData(key);
                }

                Owner.ObservableViewModelService.NotifyNodeInitialized(this);
            }

            FinalizeChildrenInitialization();

            CheckDynamicMemberConsistency();
        }
        public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, IReadOnlyList <NodeCommandWrapperBase> commands)
            : base(serviceProvider)
        {
            if (commands == null)
            {
                throw new ArgumentNullException(nameof(commands));
            }
            if (commands.Count == 0)
            {
                throw new ArgumentException(@"The collection of commands to combine is empty", nameof(commands));
            }

            firstCommand = commands[0] as ModelNodeCommandWrapper;
            if (firstCommand != null && commands.OfType <ModelNodeCommandWrapper>().Any(x => !ReferenceEquals(x.NodeCommand, firstCommand.NodeCommand)))
            {
                throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", nameof(commands));
            }

            this.commands = commands;
            Name          = name;
        }
예제 #7
0
        internal protected virtual void Initialize()
        {
            var targetNode = GetTargetNode(SourceNode, Index);
            var targetNodePath = SourceNodePath.GetChildPath(SourceNode, targetNode);
            if (targetNodePath == null || !targetNodePath.IsValid)
                throw new InvalidOperationException("Unable to retrieve the path of the given model node.");

            var commandPath = targetNodePath;
            if ((!SourceNode.Content.ShouldProcessReference || targetNode == SourceNode || targetNode == null) && Index != null)
            {
                // When the references are not processed or when the value is null, there is no actual target node.
                // However, the commands need the index to be able to properly set the modified value
                commandPath = targetNodePath.PushElement(Index, GraphNodePath.ElementType.Index);
            }

            if (targetNode != SourceNode && targetNode != null)
            {
                foreach (var command in targetNode.Commands)
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, commandPath, Owner.Dirtiables);
                    AddCommand(commandWrapper);
                }
            }

            var targetCommandNames = Commands.Select(x => x.Name).ToList();
            foreach (var command in SourceNode.Commands)
            {
                // Add source commands that are not already provided by the target node
                if (!targetCommandNames.Contains(command.Name))
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, commandPath, Owner.Dirtiables);
                    AddCommand(commandWrapper);
                }
            }

            if (!isPrimitive && targetNode != null)
            {
                GenerateChildren(targetNode, targetNodePath);
            }

            isInitialized = true;

            Owner.ObservableViewModelService?.NotifyNodeInitialized(this);

            FinalizeChildrenInitialization();

            CheckDynamicMemberConsistency();
        }
예제 #8
0
        internal protected virtual void Initialize()
        {
            var targetNodePath = SourceNodePath.GetChildPath(SourceNode, targetNode);
            if (targetNodePath == null || !targetNodePath.IsValid)
                throw new InvalidOperationException("Unable to retrieve the path of the given model node.");

            if (!targetNode.Content.ShouldProcessReference && Index != null)
            {
                // When the references are not processed, there is no actual target node.
                // However, the commands need the index to be able to properly set the modified value
                targetNodePath = targetNodePath.PushElement(Index, ModelNodePath.ElementType.Index);
            }

            foreach (var command in targetNode.Commands)
            {
                var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, Path, Owner, targetNodePath, Owner.Dirtiables);
                AddCommand(commandWrapper);
            }

            if (!isPrimitive)
                GenerateChildren(targetNode, targetNodePath);

            isInitialized = true;

            if (Owner.ObservableViewModelService != null)
            {
                foreach (var key in AssociatedData.Keys.ToList())
                {
                    RemoveAssociatedData(key);
                }

                Owner.ObservableViewModelService.NotifyNodeInitialized(this);
            }

            FinalizeChildrenInitialization();
            
            CheckDynamicMemberConsistency();
        }
        protected internal void Initialize()
        {
            var targetNode = GetTargetNode(SourceNode, Index);

            if (targetNode != SourceNode && targetNode != null)
            {
                foreach (var command in targetNode.Commands)
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, SourceNodePath, Index);
                    AddCommand(commandWrapper);
                }
            }

            var targetCommandNames = Commands.Select(x => x.Name).ToList();
            foreach (var command in SourceNode.Commands)
            {
                // Add source commands that are not already provided by the target node
                if (!targetCommandNames.Contains(command.Name))
                {
                    var commandWrapper = new ModelNodeCommandWrapper(ServiceProvider, command, SourceNodePath, Index);
                    AddCommand(commandWrapper);
                }
            }

            if (!isPrimitive && targetNode != null)
            {
                var targetNodePath = GetTargetNodePath();
                if (targetNodePath == null || !targetNodePath.IsValid)
                    throw new InvalidOperationException("Unable to retrieve the path of the given model node.");

                GenerateChildren(targetNode, targetNodePath);
            }

            isInitialized = true;

            Owner.ObservableViewModelService?.NotifyNodeInitialized(this);

            FinalizeChildrenInitialization();

            CheckDynamicMemberConsistency();
        }