Example #1
0
        public override void Loaded(UFrameContainer container)
        {
            base.Loaded(container);
            FlagByName.Clear();
            foreach (var item in InvertApplication.GetDerivedTypes <IDiagramNodeItem>())
            {
                var flagProperties = item.GetProperties(BindingFlags.Default | BindingFlags.Public | BindingFlags.Instance).Where(p => p.IsDefined(typeof(NodeFlag), true)).ToArray();
                foreach (var property in flagProperties)
                {
                    var attr = property.GetCustomAttributes(typeof(NodeFlag), true).OfType <NodeFlag>().FirstOrDefault();
                    FlagByName.Add(attr.Name, new FlagConfig(item, attr.Name, attr.Color)
                    {
                        PropertyInfo = property
                    });
                }
            }

            foreach (var item in container.ResolveAll <FlagConfig>())
            {
                FlagByName.Add(item.FlagName, item);
            }
        }
Example #2
0
        //public NodeConfig<TNode> Validator(Func<TNode, bool> validate, string message, ValidatorType validatorType = ValidatorType.Warning)
        //{
        //    Validators.Add(new NodeValidator<TNode>()
        //    {
        //        Validate = validate,
        //        Message = message,
        //        Type = validatorType

        //    });
        //    return this;
        //}
#if !SERVER
        public NodeConfig <TNode> LoadDerived <TViewModel>(Action <NodeConfig <TNode>, Type> configure = null)
        {
            foreach (var item in InvertApplication.GetDerivedTypes <TNode>(false, false))
            {
                Container.RegisterRelation(item, typeof(ViewModel), typeof(TViewModel));

                var config = new NodeConfig <TNode>(Container);
                config.NodeType = item;
                Container.RegisterInstance <NodeConfigBase>(config, item.Name);
                config.Name = item.Name.Replace("Shell", "").Replace("Node", "");
                //config.Tags.Add(config.Name);
                if (configure != null)
                {
                    configure(config, item);
                }
                else
                {
                    HasSubNode(item);
                }
            }
            return(this);
        }