public void RegisterBaseToDerived(IAssetNode baseNode, IAssetNode derivedNode) { var ownerPart = derivedNode.GetContent(NodesToOwnerPartVisitor.OwnerPartContentName); var instanceId = (ownerPart?.Retrieve() as IAssetPartDesign)?.Base?.InstanceId ?? Guid.Empty; AssetBaseToDerivedRegistry derivedRegistry; if (!baseToInstances.TryGetValue(instanceId, out derivedRegistry)) { baseToInstances[instanceId] = derivedRegistry = new AssetBaseToDerivedRegistry(propertyGraph); } derivedRegistry.RegisterBaseToDerived(baseNode, derivedNode); }
private void RelinkToOwnerPart([NotNull] IAssetNode node, object newValue) { var partDesign = (TAssetPartDesign)node.GetContent(NodesToOwnerPartVisitor.OwnerPartContentName)?.Retrieve(); if (partDesign != null) { // A property of a part has changed LinkToOwnerPart(node, partDesign); } else if (node.Type == typeof(AssetPartCollection <TAssetPartDesign, TAssetPart>) && newValue is TAssetPartDesign) { // A new part has been added partDesign = (TAssetPartDesign)newValue; LinkToOwnerPart(Container.NodeContainer.GetNode(partDesign.Part), partDesign); } }
public IIdentifiable ResolveFromBase(object baseObjectReference, IAssetNode derivedReferencerNode) { if (derivedReferencerNode == null) { throw new ArgumentNullException(nameof(derivedReferencerNode)); } var ownerPart = derivedReferencerNode.GetContent(NodesToOwnerPartVisitor.OwnerPartContentName); var instanceId = (ownerPart?.Retrieve() as IAssetPartDesign)?.Base?.InstanceId ?? Guid.Empty; AssetBaseToDerivedRegistry derivedRegistry; if (!baseToInstances.TryGetValue(instanceId, out derivedRegistry)) { return(null); } return(derivedRegistry.ResolveFromBase(baseObjectReference, derivedReferencerNode)); }
protected internal override object CloneValueFromBase(object value, IAssetNode node) { var part = value as TAssetPart; // Part reference if (part != null) { // We need to find out for which entity we are cloning this (other) entity var owner = (TAssetPartDesign)node?.GetContent(NodesToOwnerPartVisitor.OwnerPartContentName).Retrieve(); if (owner != null) { // Then instead of creating a clone, we just return the corresponding part in this asset (in term of base and base instance) var partInDerived = AssetHierarchy.Hierarchy.Parts.FirstOrDefault(x => x.Base?.BasePartId == part.Id && x.Base?.InstanceId == owner.Base?.InstanceId); return(partInDerived?.Part); } } var result = base.CloneValueFromBase(value, node); return(result); }
public void Visit([NotNull] IAssetNode node, NodeIndex index) { if (index == NodeIndex.Empty) { // Normal case, no index Visit(node); } else if (node.IsReference) { // We have an index, and our collection is a collection of reference types, then start visit from the target item var target = ((IObjectNode)node).IndexedTarget(index); if (target != null) { Visit(target); } } else if (AssetRegistry.IsContentType(node.Descriptor.GetInnerCollectionType())) { // We have an index, and our collection is directly a collection of content type. Let's just collect the corresponding item. var gameContent = node.GetContent("Game"); var id = AttachedReferenceManager.GetAttachedReference(node.Retrieve(index))?.Id ?? AssetId.Empty; CollectContentReference(id, gameContent, index); } }