Beispiel #1
0
        /// <summary>
        /// Visits the <see cref="FieldInfoElement"/> and collects the value for this
        /// field from the <see cref="Target"/> instance.
        /// </summary>
        /// <param name="fieldInfoElement">
        /// The <see cref="FieldInfoElement"/> being visited.
        /// </param>
        /// <returns>
        /// A <see cref="IReflectionVisitor{T}" /> instance which can be used
        /// to continue the visiting process with potentially updated
        /// observations.
        /// </returns>
        public override IReflectionVisitor <IEnumerable <object> > Visit(
            FieldInfoElement fieldInfoElement)
        {
            if (fieldInfoElement == null)
            {
                throw new ArgumentNullException("fieldInfoElement");
            }

            var value = fieldInfoElement.FieldInfo.GetValue(this.target);

            return(new ValueCollectingVisitor(
                       this.target,
                       this.values.Concat(new[] { value }).ToArray()));
        }
 /// <summary>
 /// Allows an <see cref="FieldInfoElement"/> to be visited.
 /// This method is called when the element accepts this visitor
 /// instance.
 /// </summary>
 /// <param name="fieldInfoElement">
 /// The <see cref="FieldInfoElement"/> being visited.
 /// </param>
 /// <returns>
 /// A <see cref="IReflectionVisitor{T}" /> instance which can be used
 /// to continue the visiting process with potentially updated
 /// observations.
 /// </returns>
 /// <remarks>
 /// <para>
 /// This implementation simply returns
 /// <paramref name="fieldInfoElement" /> without doing anything,
 /// but since the method is virtual, child classes can override it.
 /// </para>
 /// </remarks>
 public virtual IReflectionVisitor <T> Visit(
     FieldInfoElement fieldInfoElement)
 {
     return(this);
 }