Пример #1
0
        private static GraphReference New(GraphPointer model)
        {
            var reference = new GraphReference();

            reference.CopyFrom(model);
            return(reference);
        }
Пример #2
0
        internal static GraphStack New(GraphPointer model)
        {
            var stack = GenericPool <GraphStack> .New(() => new GraphStack());

            stack.CopyFrom(model);
            return(stack);
        }
Пример #3
0
        public static GraphReference Intern(GraphPointer pointer)
        {
            var hash = pointer.ComputeHashCode();

            if (internPool.TryGetValue(hash, out var interns))
            {
                foreach (var intern in interns)
                {
                    if (intern.InstanceEquals(pointer))
                    {
                        return(intern);
                    }
                }

                var reference = New(pointer);
                interns.Add(reference);
                return(reference);
            }
            else
            {
                var reference = New(pointer);
                internPool.Add(reference.hashCode, new List <GraphReference>()
                {
                    reference
                });
                return(reference);
            }
        }
        public static void HandleException(this IGraphElementWithDebugData element, GraphPointer pointer, Exception ex)
        {
            Ensure.That(nameof(ex)).IsNotNull(ex);

            if (pointer == null)
            {
                Debug.LogError("Caught exception with null graph pointer (flow was likely disposed):\n" + ex);
                return;
            }

            var reference = pointer.AsReference();

            if (!ex.HandledIn(reference))
            {
                element.SetException(pointer, ex);
            }

            while (reference.isChild)
            {
                var parentElement = reference.parentElement;
                reference = reference.ParentReference(true);

                if (parentElement is IGraphElementWithDebugData debuggableParentElement)
                {
                    if (!ex.HandledIn(reference))
                    {
                        debuggableParentElement.SetException(reference, ex);
                    }
                }
            }
        }
        public static GraphPointerData FromPointer(GraphPointer pointer)
        {
            if (pointer == null || !pointer.isValid)
            {
                return(null);
            }

            return(new GraphPointerData(pointer));
        }
        public static void SetException(this IGraphElementWithDebugData element, GraphPointer pointer, Exception ex)
        {
            if (!pointer.hasDebugData)
            {
                return;
            }

            var debugData = pointer.GetElementDebugData <IGraphElementDebugData>(element);

            debugData.runtimeException = ex;
        }
Пример #7
0
        public override void CopyFrom(GraphPointer other)
        {
            base.CopyFrom(other);

            if (other is GraphReference reference)
            {
                hashCode = reference.hashCode;
            }
            else
            {
                Hash();
            }
        }
Пример #8
0
        public virtual void CopyFrom(GraphPointer other)
        {
            root       = other.root;
            gameObject = other.gameObject;

            parentStack.Clear();
            parentElementStack.Clear();
            graphStack.Clear();
            dataStack.Clear();
            debugDataStack.Clear();

            foreach (var parent in other.parentStack)
            {
                parentStack.Add(parent);
            }

            foreach (var parentElement in other.parentElementStack)
            {
                parentElementStack.Add(parentElement);
            }

            foreach (var graph in other.graphStack)
            {
                graphStack.Add(graph);
            }

            foreach (var data in other.dataStack)
            {
                dataStack.Add(data);
            }

            foreach (var debugData in other.debugDataStack)
            {
                debugDataStack.Add(debugData);
            }
        }
        public static Exception GetException(this IGraphElementWithDebugData element, GraphPointer pointer)
        {
            if (!pointer.hasDebugData)
            {
                return(null);
            }

            var debugData = pointer.GetElementDebugData <IGraphElementDebugData>(element);

            return(debugData.runtimeException);
        }
Пример #10
0
 private GraphPointerData(GraphPointer pointer)
 {
     rootObjectInstanceID = pointer.rootObject.GetInstanceID();
     parentElementGuids   = pointer.parentElementGuids.ToArray();
 }
Пример #11
0
 public GraphPointerException(string message, GraphPointer pointer) : base(message + "\n" + pointer)
 {
     this.pointer = pointer;
 }