public FutureInstanceVisitor(ObjectCallerBase <T> handler, ObjectVisitorOptions options, IDictionary <string, object> initialValues = null) { _options = options?.Clone() ?? ObjectVisitorOptions.Default; _handler = handler ?? throw new ArgumentNullException(nameof(handler)); SourceType = typeof(T); _handler.New(); GenericHistoricalContext = _options.Repeatable ? new HistoricalContext <T>(_options.AlgorithmKind) : null; _objectOwnInfo = ObjectOwn.Of <T>(); _lazyMemberHandler = MemberHandler.Lazy(_handler, SourceType, _options.LiteMode); _correctnessContext = _options.StrictMode ? new CorrectnessContext <T>(this, true) : null; if (initialValues is not null) { SetValue(initialValues); } LazyPropertyNodes = RootNode.New(_handler, _options); }
public static bool ReadOnly(ObjectOwn own, ObjectVisitorOptions options) { if (!own.IsReadOnly) { return(false); } if (options.SilenceIfNotWritable) { return(true); } throw new InvalidOperationException($"This type ({own.Type.GetFriendlyName()}) is read only."); }
public StaticTypeObjectVisitor(ObjectCallerBase handler, Type targetType, ObjectVisitorOptions options) { _options = options?.Clone() ?? ObjectVisitorOptions.Default; _handler = handler ?? throw new ArgumentNullException(nameof(handler)); SourceType = targetType ?? throw new ArgumentNullException(nameof(targetType)); _objectOwnInfo = ObjectOwn.Of(targetType); _lazyMemberHandler = MemberHandler.Lazy(_handler, SourceType, _options.LiteMode); _correctnessContext = _options.StrictMode ? new CorrectnessContext(this, true) : null; LazyPropertyNodes = RootNode.New(_handler, _options.Clone(x => x.Repeatable = RpMode.NON_REPEATABLE)); }
public InstanceVisitor(ObjectCallerBase handler, Type sourceType, ObjectVisitorOptions options) { _options = options?.Clone() ?? ObjectVisitorOptions.Default; _handler = handler ?? throw new ArgumentNullException(nameof(handler)); SourceType = sourceType ?? throw new ArgumentNullException(nameof(sourceType)); NormalHistoricalContext = _options.Repeatable ? new HistoricalContext(sourceType, _options.AlgorithmKind) : null; _objectOwnInfo = ObjectOwn.Of(sourceType); _lazyMemberHandler = MemberHandler.Lazy(_handler, SourceType, _options.LiteMode); _correctnessContext = _options.StrictMode ? new CorrectnessContext(this, true) : null; LazyPropertyNodes = RootNode.New(_handler, _options); }