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); }
public override void AddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers) { var subEntity = (EntityViewModel)children.First(); var command = TargetNode.GetCommand(SetEntityReferenceCommand.CommandName); command.Execute(subEntity); }
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); }
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); }
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 }); } }