Example #1
0
        bool IAppender.Append(AppenderContext context)
        {
            if (context.Container == null || context.Value == null)
            {
                return(false);
            }

            if (this.Append(context.Container, context.Value, context.Node.Name))
            {
                return(true);
            }

            var names = new string[] { "Children", "Items", "Nodes", "Controls" };

            foreach (string name in names)
            {
                //获取插入属性的反射对象
                var property = context.Container.GetType().GetProperty(name, (BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty));

                if (property != null)
                {
                    object children = property.GetValue(context.Container, null);

                    if (this.Append(children, context.Value, context.Node.Name))
                    {
                        return(true);
                    }
                }
            }

            //最后返回失败
            return(false);
        }
Example #2
0
        bool IAppender.Append(AppenderContext context)
        {
            if (context.Container == null || context.Value == null)
            {
                return(false);
            }

            return(this.Append(context.Container, context.Value, context.Node.Name));
        }
Example #3
0
        bool IAppender.Append(AppenderContext context)
        {
            if (context.Container == null || context.Value == null)
            {
                return(false);
            }

            var category = context.Value as Category;

            if (category != null)
            {
                ((Category)context.Container).Children.Add(category);
            }

            return(true);
        }
        bool IAppender.Append(AppenderContext context)
        {
            var commandNode = context.Container as CommandTreeNode;

            if (commandNode != null)
            {
                if (context.Value is ICommand)
                {
                    commandNode.Children.Add((ICommand)context.Value);
                }
                else if (context.Value is CommandTreeNode)
                {
                    commandNode.Children.Add((CommandTreeNode)context.Value);
                }
                else
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }