public static IPropertyNodeVisitor Create(ObjectMember member, ObjectCallerBase parentHandlerPtr, ObjectVisitorOptions options)
        {
            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, visitor, options, MemberValueSyncHandler));
        }
Exemple #2
0
        public static InstanceVisitor <T> CreateForInstance <T, TStrategy>(T instance, ObjectVisitorOptions options)
            where TStrategy : class, IValidationStrategy <T>, new()
        {
            options ??= ObjectVisitorOptions.Default;
            var handler = UnsafeObjectHandleSwitcher.Switch <T>(options.AlgorithmKind)().AndSetInstance(instance).With <T>();
            var visitor = new InstanceVisitor <T>(handler, options);

            visitor.VerifiableEntry.SetStrategy <TStrategy>();
            return(visitor);
        }
Exemple #3
0
        public static InstanceVisitor CreateForInstance <TStrategy>(Type type, object instance, ObjectVisitorOptions options, TStrategy strategy)
            where TStrategy : class, IValidationStrategy, new()
        {
            options ??= ObjectVisitorOptions.Default;
            var handler = SafeObjectHandleSwitcher.Switch(options.AlgorithmKind)(type).AndSetInstance(instance);
            var visitor = new InstanceVisitor(handler, type, options);

            visitor.VerifiableEntry.SetStrategy(strategy);
            return(visitor);
        }
Exemple #4
0
        //root

        public PropertyNodeVisitor(
            ObjectMember member,
            InstanceVisitor visitor,
            ObjectVisitorOptions options,
            Action <object> memberValueSyncHandler)
        {
            _options               = options ?? throw new ArgumentNullException(nameof(options));
            _member                = member ?? throw new ArgumentNullException(nameof(member));
            Deep                   = 0;
            Root                   = this;
            Parent                 = null;
            _visitor               = visitor ?? throw new ArgumentNullException(nameof(visitor));
            _signature             = visitor.Signature;
            _rootSignatureCached   = new() { _signature };
            _parentSignatureCached = default;
            _signatureCached       = new() { _signature };
            _childrenNodes         = new();
            MemberValueSyncHandler = memberValueSyncHandler ?? throw new ArgumentNullException(nameof(memberValueSyncHandler));
        }
Exemple #5
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);
        }
 private ClassDefinition ClassDefinition;                                         //Contien las variables estaticas tambien
 internal ClassInstance(InstanceVisitor visitor, ClassDefinition classDefinition) //Solo puede ser usado por class definition
 {
     Visitor         = visitor;
     ClassDefinition = classDefinition;
     Calculator      = CustomInstanceOperation.GetInstance();
 }