public static IPropertyNodeVisitor Create(
            ObjectMember member, ObjectCallerBase parentHandlerPtr, ObjectVisitorOptions options,
            PropertyNodeVisitor rootVisitor, PropertyNodeVisitor parentVisitor, List <int> rootSignatureCacheRef, List <int> parentSignatureCacheRef, int deep)
        {
            void MemberValueSyncHandler(object instance) => parentHandlerPtr[member.MemberName] = instance;

            var handler = SafeObjectHandleSwitcher.Switch(options.AlgorithmKind)(member.MemberType).AndSetInstance(parentHandlerPtr.GetObject(member.MemberName));
            var visitor = new InstanceVisitor(handler, member.MemberType, options);

            return(new PropertyNodeVisitor(member, rootVisitor, parentVisitor, visitor, options, MemberValueSyncHandler, rootSignatureCacheRef, parentSignatureCacheRef, deep + 1));
        }
Exemplo n.º 2
0
        //child

        public PropertyNodeVisitor(
            ObjectMember member,
            PropertyNodeVisitor rootVisitor, PropertyNodeVisitor parentVisitor, InstanceVisitor visitor,
            ObjectVisitorOptions options,
            Action <object> memberValueSyncHandler,
            List <int> rootSignatureCacheRef, List <int> parentSignatureCacheRef,
            int deep)
        {
            _member                = member ?? throw new ArgumentNullException(nameof(member));
            Deep                   = deep;
            Root                   = rootVisitor ?? throw new ArgumentNullException(nameof(rootVisitor));
            Parent                 = parentVisitor ?? throw new ArgumentNullException(nameof(parentVisitor));
            _visitor               = visitor ?? throw new ArgumentNullException(nameof(visitor));
            _signature             = visitor.Signature;
            _rootSignatureCached   = rootSignatureCacheRef;
            _parentSignatureCached = parentSignatureCacheRef;
            _signatureCached       = new() { _signature };
            _childrenNodes         = new();
            MemberValueSyncHandler = memberValueSyncHandler ?? throw new ArgumentNullException(nameof(memberValueSyncHandler));

            _rootSignatureCached.Add(_signature);
            _parentSignatureCached.Add(_signature);
        }