示例#1
0
        /// <inheritdoc/>
        public override void VisitObjectMember(object container, ObjectDescriptor containerDescriptor, IMemberDescriptor member, object value)
        {
            if (!NotifyNodeConstructing(containerDescriptor, member))
            {
                return;
            }

            // If this member should contains a reference, create it now.
            IReference      reference      = CreateReferenceForNode(member.Type, value);
            ModelNode       containerNode  = GetContextNode();
            ITypeDescriptor typeDescriptor = TypeDescriptorFactory.Find(member.Type);
            IContent        content        = new MemberContent(containerNode.Content, member, typeDescriptor, IsPrimitiveType(member.Type), reference);
            var             node           = new ModelNode(member.Name, content, Guid.NewGuid());

            containerNode.AddChild(node);

            if (reference != null)
            {
                referenceContents.Add(content);
            }

            if (!(reference is ObjectReference))
            {
                // For enumerable references, we visit the member to allow VisitCollection or VisitDictionary to enrich correctly the node.
                PushContextNode(node);
                Visit(value);
                PopContextNode();
            }

            AvailableCommands.Where(x => x.CanAttach(node.Content.Descriptor, (MemberDescriptorBase)member)).ForEach(node.AddCommand);
            NotifyNodeConstructed(content);

            node.Seal();
        }
示例#2
0
        /// <inheritdoc/>
        public override void VisitObjectMember(object container, ObjectDescriptor containerDescriptor, IMemberDescriptor member, object value)
        {
            bool shouldProcessReference;

            if (!NotifyNodeConstructing(containerDescriptor, member, out shouldProcessReference))
            {
                return;
            }

            // If this member should contains a reference, create it now.
            ModelNode containerNode = GetContextNode();
            IContent  content       = ContentFactory.CreateMemberContent(this, containerNode.Content, member, IsPrimitiveType(member.Type), value, shouldProcessReference);
            var       node          = new ModelNode(member.Name, content, Guid.NewGuid());

            containerNode.AddChild(node);

            if (content.IsReference)
            {
                referenceContents.Add(content);
            }

            PushContextNode(node);
            if (!(content.Reference is ObjectReference))
            {
                // For enumerable references, we visit the member to allow VisitCollection or VisitDictionary to enrich correctly the node.
                Visit(content.Value);
            }
            PopContextNode();

            AvailableCommands.Where(x => x.CanAttach(node.Content.Descriptor, (MemberDescriptorBase)member)).ForEach(node.AddCommand);
            NotifyNodeConstructed(content);

            node.Seal();
        }