/// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public override T Build(object obj)
        {
            if (!(obj is IEnumerable enumerable))
            {
                return(new T());
            }

            var result = new T();

            result.Initialize(new TreeItemNodeInitializeArgs(obj));

            foreach (var item in enumerable)
            {
                var builder = TreeItemTypeBuilderFactory.GetTreeItemTypeBuilder(item);
                if (builder == null)
                {
                    continue;
                }

                var child = builder.Build(item);
                result.AddChild(child);
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="property"></param>
        /// <param name="propValue"></param>
        /// <param name="parent"></param>
        public override void BuildChild(PropertyInfo property, object propValue, ITreeItemNode parent)
        {
            if (!(propValue is IDictionary dictionary))
            {
                return;
            }

            var result = new T();

            result.Initialize(new TreeItemNodeInitializeArgs(dictionary));

            foreach (var item in dictionary)
            {
                var builder = TreeItemTypeBuilderFactory.GetTreeItemTypeBuilder(item);
                if (builder == null)
                {
                    continue;
                }

                var child = builder.Build(item);
                result.AddChild(child);
            }

            parent?.AddChild(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="property"></param>
        /// <param name="propValue"></param>
        /// <param name="parent"></param>
        public override void BuildChild(PropertyInfo property, object propValue, ITreeItemNode parent)
        {
            var builder = TreeItemTypeBuilderFactory.GetTreeItemTypeBuilder(property.PropertyType);

            if (builder == null)
            {
                return;
            }

            var child = builder.Build(propValue);

            parent.AddChild(child);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public override T Build(object obj)
        {
            var result = new T();

            result.Initialize(new TreeItemNodeInitializeArgs(obj));
            if (obj == null)
            {
                return(result);
            }

            foreach (var property in obj.GetType().GetProperties())
            {
                var propValue = property.GetValue(obj);
                var builder   = TreeItemTypeBuilderFactory.GetTreeItemTypeBuilder(property.PropertyType);
                builder?.BuildChild(property, propValue, result);
            }

            return(result);
        }