示例#1
0
        public NodeConfigSection <TNode> ReferenceSection <TSourceType, TReferenceItem>(string header,
                                                                                        Func <TNode, IEnumerable <TSourceType> > selector,
                                                                                        bool manual          = false,
                                                                                        bool allowDuplicates = false)
            where TReferenceItem : GenericReferenceItem
        //where TSourceType : IGraphItem
        {
            //Container.RegisterGraphItem<TReferenceItem, ScaffoldNodeChildItem<TReferenceItem>.ViewModel, ScaffoldNodeChildItem<TReferenceItem>.Drawer>();
            var section = new NodeConfigSection <TNode>()
            {
                SourceType      = typeof(TReferenceItem),
                Name            = header,
                AllowAdding     = manual,
                ReferenceType   = typeof(TSourceType),
                AllowDuplicates = allowDuplicates
            };

            if (selector != null)
            {
                section.Selector = p => selector(p).Cast <IGraphItem>();
            }
            else
            {
                throw new Exception("Reference Section must have a selector");
            }
            GraphItemConfigurations.Add(section);
            return(section);
        }
示例#2
0
 public NodeConfig<TNode> InputAlias(string inputName)
 {
     var config = new NodeInputConfig()
     {
         Name = new ConfigProperty<IDiagramNodeItem, string>(inputName),
         IsInput = true,
         IsOutput = false,
         SourceType = typeof(TNode),
         ReferenceType = typeof(TNode),
         IsAlias = true
     };
     GraphItemConfigurations.Add(config);
     return this;
 }
示例#3
0
 public NodeConfigSection<TNode> Proxy<TChildItem>(string header, Func<TNode, IEnumerable<TChildItem>> selector = null)
 {
     var section = new NodeConfigSection<TNode>()
     {
         SourceType = typeof(TChildItem),
         Name = header,
         IsProxy = true,
         AllowAdding = false
     };
     if (selector != null)
     {
         section.Selector = p => selector(p).Cast<IGraphItem>();
     }
     GraphItemConfigurations.Add(section);
     return section;
 }
示例#4
0
 public NodeConfig<TNode> Input<TSourceType, TReferenceType>(string inputName, bool allowMultiple, Func<IDiagramNodeItem, IDiagramNodeItem, bool> validator = null)
     where TSourceType : class, IConnectable
     where TReferenceType : GenericSlot, new()
 {
     var config = new NodeInputConfig()
     {
         Name = new ConfigProperty<IDiagramNodeItem, string>(inputName),
         IsInput = true,
         IsOutput = false,
         ReferenceType = typeof(TReferenceType),
         SourceType = typeof(TSourceType),
         Validator = validator
     };
     GraphItemConfigurations.Add(config);
     return this;
 }
示例#5
0
        public NodeConfigSection <TNode> Section <TChildItem>(string header, Func <TNode, IEnumerable <TChildItem> > selector = null, bool allowAdding = true, Action <TChildItem> onAdd = null)
        {
            var section = new NodeConfigSection <TNode>()
            {
                SourceType = typeof(TChildItem),
                Name       = header,

                IsProxy     = false,
                AllowAdding = allowAdding
            };

            if (onAdd != null)
            {
                section.OnAdd = p => onAdd((TChildItem)p);
            }
            if (selector != null)
            {
                section.Selector = p => selector(p).Cast <IGraphItem>();
            }
            GraphItemConfigurations.Add(section);
            return(section);
        }