Example #1
0
        public static HashSet <IIdentifiable> GetExternalReferences([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition, [NotNull] IGraphNode root)
        {
            var visitor = new ExternalReferenceCollector(propertyGraphDefinition);

            visitor.Visit(root);
            // An IIdentifiable can have been recorded both as internal and external reference. In this case we still want to clone it so let's remove it from external references
            visitor.externalReferences.ExceptWith(visitor.internalReferences);
            return(visitor.externalReferences);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClearObjectReferenceVisitor"/> class.
 /// </summary>
 /// <param name="propertyGraphDefinition">The <see cref="AssetPropertyGraphDefinition"/> used to analyze object references.</param>
 /// <param name="targetIds">The identifiers of the objects for which to clear references.</param>
 /// <param name="shouldClearReference">A method allowing to select which object reference to clear. If null, all object references to the given id will be cleared.</param>
 public ClearObjectReferenceVisitor([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition, [NotNull] IEnumerable <Guid> targetIds, [CanBeNull] Func <IGraphNode, NodeIndex, bool> shouldClearReference = null)
     : base(propertyGraphDefinition)
 {
     if (propertyGraphDefinition == null)
     {
         throw new ArgumentNullException(nameof(propertyGraphDefinition));
     }
     if (targetIds == null)
     {
         throw new ArgumentNullException(nameof(targetIds));
     }
     this.targetIds            = new HashSet <Guid>(targetIds);
     this.shouldClearReference = shouldClearReference;
 }
        public static Dictionary <Guid, IIdentifiable> Collect([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition, [NotNull] IGraphNode rootNode)
        {
            if (propertyGraphDefinition == null)
            {
                throw new ArgumentNullException(nameof(propertyGraphDefinition));
            }
            if (rootNode == null)
            {
                throw new ArgumentNullException(nameof(rootNode));
            }
            var visitor = new IdentifiableObjectCollector(propertyGraphDefinition);

            visitor.Visit(rootNode);
            return(visitor.result);
        }
            public static Dictionary <SharedRendererReferenceKey, ISharedRenderer> GetExternalReferences(AssetPropertyGraphDefinition propertyGraphDefinition, IEnumerable <IGraphNode> rootNodes)
            {
                var visitor = new SharedRendererReferenceVisitor(propertyGraphDefinition);

                foreach (var rootNode in rootNodes)
                {
                    visitor.Visit(rootNode);
                }
                return(visitor.externalReferences);
            }
 private SharedRendererReferenceVisitor(AssetPropertyGraphDefinition propertyGraphDefinition)
     : base(propertyGraphDefinition)
 {
 }
Example #6
0
 public ContentReferenceCollector([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition)
     : base(propertyGraphDefinition)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetGraphVisitorBase"/> class.
 /// </summary>
 /// <param name="propertyGraphDefinition">The <see cref="AssetPropertyGraphDefinition"/> used to analyze object references.</param>
 public AssetGraphVisitorBase([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition)
 {
     PropertyGraphDefinition = propertyGraphDefinition ?? throw new ArgumentNullException(nameof(propertyGraphDefinition));
 }
Example #8
0
        /// <summary>
        /// Computes the external references to the given root node and their accessors.
        /// </summary>
        /// <param name="propertyGraphDefinition">The property graph definition to use to analyze the graph.</param>
        /// <param name="root">The root node to analyze.</param>
        /// <returns>A set containing all external references to identifiable objects.</returns>
        public static Dictionary <IIdentifiable, List <NodeAccessor> > GetExternalReferenceAccessors([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition, [NotNull] IGraphNode root)
        {
            var visitor = new ExternalReferenceCollector(propertyGraphDefinition);

            visitor.Visit(root);
            // An IIdentifiable can have been recorded both as internal and external reference. In this case we still want to clone it so let's remove it from external references
            foreach (var internalReference in visitor.internalReferences)
            {
                visitor.externalReferenceAccessors.Remove(internalReference);
            }
            return(visitor.externalReferenceAccessors);
        }
Example #9
0
 private ExternalReferenceCollector([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition)
     : base(propertyGraphDefinition)
 {
     this.propertyGraphDefinition = propertyGraphDefinition;
 }
 /// <summary>
 /// Initializes a new instance of hte <see cref="IdentifiableObjectVisitorBase"/> class.
 /// </summary>
 /// <param name="propertyGraphDefinition">The <see cref="AssetPropertyGraphDefinition"/> used to analyze object references.</param>
 protected IdentifiableObjectVisitorBase([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition)
     : base(propertyGraphDefinition)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IdentifiableObjectCollector"/> class.
 /// </summary>
 /// <param name="propertyGraphDefinition">The <see cref="AssetPropertyGraphDefinition"/> used to analyze object references.</param>
 private IdentifiableObjectCollector([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition)
     : base(propertyGraphDefinition)
 {
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectReferencePathGenerator"/> class.
 /// </summary>
 /// <param name="propertyGraphDefinition">The <see cref="AssetPropertyGraphDefinition"/> used to analyze object references.</param>
 public ObjectReferencePathGenerator(AssetPropertyGraphDefinition propertyGraphDefinition)
 {
     this.propertyGraphDefinition = propertyGraphDefinition;
 }