Exemplo n.º 1
0
        public GraphElementSearcherDatabase AddNodesWithSearcherItemAttribute()
        {
            var types = TypeCache.GetTypesWithAttribute <SearcherItemAttribute>();

            foreach (var type in types)
            {
                var attributes = type.GetCustomAttributes <SearcherItemAttribute>().ToList();
                if (!attributes.Any())
                {
                    continue;
                }

                foreach (var attribute in attributes)
                {
                    if (!attribute.StencilType.IsInstanceOfType(Stencil))
                    {
                        continue;
                    }

                    var name = attribute.Path.Split('/').Last();
                    var path = attribute.Path.Remove(attribute.Path.LastIndexOf('/') + 1);

                    switch (attribute.Context)
                    {
                    case SearcherContext.Graph:
                    {
                        var node = new GraphNodeModelSearcherItem(
                            new NodeSearcherItemData(type),
                            data => data.CreateNode(type, name),
                            name
                            );
                        Items.AddAtPath(node, path);
                        break;
                    }

                    case SearcherContext.Stack:
                    {
                        var node = new StackNodeModelSearcherItem(
                            new NodeSearcherItemData(type),
                            data => data.CreateNode(type, name),
                            name
                            );
                        Items.AddAtPath(node, path);
                        break;
                    }

                    default:
                        Debug.LogWarning($"The node {type} is not a {SearcherContext.Stack} or " +
                                         $"{SearcherContext.Graph} node, so it cannot be add in the Searcher");
                        break;
                    }

                    break;
                }
            }

            return(this);
        }
Exemplo n.º 2
0
        public GraphElementSearcherDatabase AddInlineExpression()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.InlineExpression),
                data => data.CreateInlineExpressionNode(k_InlineLabel),
                k_InlineExpression
                );

            Items.AddAtPath(node, k_Constant);

            return(this);
        }
Exemplo n.º 3
0
        public GraphElementSearcherDatabase AddStack()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.Stack),
                data => data.CreateStack(string.Empty),
                k_Stack
                );

            Items.AddAtPath(node);

            return(this);
        }
Exemplo n.º 4
0
        public GraphElementSearcherDatabase AddEmptyFunction()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.EmptyFunction),
                data => data.CreateFunction(k_FunctionName),
                k_NewFunction
                );

            Items.AddAtPath(node);

            return(this);
        }
Exemplo n.º 5
0
        public GraphElementSearcherDatabase AddStack()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.Stack),
                data => ((VSGraphModel)data.GraphModel).CreateStack(
                    string.Empty,
                    data.Position,
                    data.SpawnFlags
                    ),
                k_Stack
                );

            Items.AddAtPath(node);

            return(this);
        }
Exemplo n.º 6
0
        public GraphElementSearcherDatabase AddGroup()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.Group),
                data => ((VSGraphModel)data.GraphModel).CreateGroup(
                    k_Group,
                    data.Position,
                    data.SpawnFlags
                    ),
                k_Group
                );

            Items.AddAtPath(node);

            return(this);
        }
Exemplo n.º 7
0
        public GraphElementSearcherDatabase AddEmptyFunction()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.EmptyFunction),
                data => ((VSGraphModel)data.GraphModel).CreateFunction(
                    k_FunctionName,
                    data.Position,
                    data.SpawnFlags
                    ),
                k_NewFunction
                );

            Items.AddAtPath(node);

            return(this);
        }
Exemplo n.º 8
0
        public GraphElementSearcherDatabase AddStickyNote()
        {
            var node = new GraphNodeModelSearcherItem(
                new SearcherItemData(SearcherItemTarget.StickyNote),
                data =>
            {
                var rect         = new Rect(data.Position, StickyNote.defaultSize);
                var vsGraphModel = (VSGraphModel)data.GraphModel;
                return(vsGraphModel.CreateStickyNote(rect, data.SpawnFlags));
            },
                k_Sticky
                );

            Items.AddAtPath(node);

            return(this);
        }