Exemple #1
0
        static void ComputeTypes()
        {
            nodeTypes = new Dictionary <int, Type>();

            foreach (var type in GetAllTypes())
            {
                GraphNodeAttribute attribute = GetAttribute(type);
                if (attribute != null)
                {
                    AddNodeType(type, attribute.type);
                }
                else if (DataAttribute.IsGraphNode(type))
                {
                    AddNodeType(typeof(GraphNode), type);
                }
            }
        }
        internal static GraphNode Create(GraphNodeView owner, Type type, DebugReference reference)
        {
            Type nodeType = GraphNodeAttribute.GetNodeType(reference.identifier.typeHashCode);

            if (nodeType != null)
            {
                Type runtimeType = DataTypes.GetTypeFromHashCode(reference.identifier.typeHashCode).Item1;

                var graphNode =
                    Activator.CreateInstance(nodeType) as GraphNode;

                if (graphNode == null)
                {
                    throw new InvalidOperationException(
                              $"Failed to create node type {nodeType.FullName} for type {type.FullName}.");
                }

                graphNode.Initialize(owner, runtimeType, reference);

                return(graphNode);
            }

            return(null);
        }