// This file is part of YamlDotNet - A .NET library for YAML. // Copyright (c) Antoine Aubry and contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies // of the Software, and to permit persons to whom the Software is furnished to do // so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. using System; namespace YamlDotNet.Serialization { /// /// Defined the interface of a type that can be notified during an object graph traversal. /// public interface IObjectGraphVisitor { /// /// Indicates whether the specified value should be entered. This allows the visitor to /// override the handling of a particular object or type. /// /// The value that is about to be entered. /// The context that this implementation depend on. /// If the value is to be entered, returns true; otherwise returns false; bool Enter(IObjectDescriptor value, TContext context); /// /// Indicates whether the specified mapping should be entered. This allows the visitor to /// override the handling of a particular pair. /// /// The key of the mapping that is about to be entered. /// The value of the mapping that is about to be entered. /// The context that this implementation depend on. /// If the mapping is to be entered, returns true; otherwise returns false; bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, TContext context); /// /// Indicates whether the specified mapping should be entered. This allows the visitor to /// override the handling of a particular pair. This overload should be invoked when the /// mapping is produced by an object's property. /// /// The that provided access to . /// The value of the mapping that is about to be entered. /// The context that this implementation depend on. /// If the mapping is to be entered, returns true; otherwise returns false; bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, TContext context); /// /// Notifies the visitor that a scalar value has been encountered. /// /// The value of the scalar. /// The context that this implementation depend on. void VisitScalar(IObjectDescriptor scalar, TContext context); /// /// Notifies the visitor that the traversal of a mapping is about to begin. /// /// The value that corresponds to the mapping. /// The static type of the keys of the mapping. /// The static type of the values of the mapping. /// The context that this implementation depend on. void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, TContext context); /// /// Notifies the visitor that the traversal of a mapping has ended. /// /// The value that corresponds to the mapping. /// The context that this implementation depend on. void VisitMappingEnd(IObjectDescriptor mapping, TContext context); /// /// Notifies the visitor that the traversal of a sequence is about to begin. /// /// The value that corresponds to the sequence. /// The static type of the elements of the sequence. /// The context that this implementation depend on. void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, TContext context); /// /// Notifies the visitor that the traversal of a sequence has ended. /// /// The value that corresponds to the sequence. /// The context that this implementation depend on. void VisitSequenceEnd(IObjectDescriptor sequence, TContext context); } }