Exemplo n.º 1
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var symbol  = (Symbol)children.Select(x => (NodeViewModel)x).First().NodeValue;
            var command = TargetNode.GetCommand(SetSymbolReferenceCommand.CommandName);

            command.Execute(symbol);
        }
Exemplo n.º 2
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var subEntity = (EntityViewModel)children.First();
            var command   = TargetNode.GetCommand(SetEntityReferenceCommand.CommandName);

            command.Execute(subEntity);
        }
Exemplo n.º 3
0
        public override bool CanAddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers, out string message)
        {
            AssetViewModel asset       = null;
            var            singleChild = true;

            foreach (var child in children)
            {
                if (!singleChild)
                {
                    message = "Multiple assets selected";
                    return(false);
                }
                asset = child as AssetViewModel;
                if (asset == null)
                {
                    message = "The selection is not an asset";
                    return(false);
                }
                if (AssetRegistry.IsContentType(TargetNode.Type) || typeof(AssetReference).IsAssignableFrom(TargetNode.Type))
                {
                    var isCompatible       = false;
                    var resolvedAssetTypes = AssetRegistry.GetAssetTypes(TargetNode.Type);
                    foreach (var resolvedAssetType in resolvedAssetTypes)
                    {
                        if (resolvedAssetType.IsAssignableFrom(asset.AssetType))
                        {
                            isCompatible = true;
                            break;
                        }
                    }
                    if (!isCompatible)
                    {
                        message = "Incompatible asset";
                        return(false);
                    }
                }
                var command = TargetNode.GetCommand("SetContentReference");
                var param   = new SetContentReferenceCommand.Parameter {
                    Asset = asset, Type = TargetNode.Type
                };
                if (!command.CanExecute(param))
                {
                    message = "The selection is not valid in this context";
                    return(false);
                }

                singleChild = false;
            }
            if (asset == null)
            {
                message = "The selection is not an asset";
                return(false);
            }
            message = $"Reference {asset.Url}";
            return(true);
        }
Exemplo n.º 4
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var asset = (AssetViewModel)children.First();
            var param = new SetContentReferenceCommand.Parameter {
                Asset = asset, Type = TargetNode.Type
            };
            var command = TargetNode.GetCommand("SetContentReference");

            command.Execute(param);
        }
Exemplo n.º 5
0
        public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers)
        {
            var subEntity = (EntityViewModel)children.First();
            var index     = subEntity.Components.IndexOf(x => TargetNode.Type.IsInstanceOfType(x));

            if (index >= 0)
            {
                var command = TargetNode.GetCommand(SetComponentReferenceCommand.CommandName);
                command.Execute(new SetComponentReferenceCommand.Parameter {
                    Entity = subEntity, Index = index
                });
            }
        }