AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Exception: WrongTypeException

Posted by Gerhard Stephan on April 21st, 2008

The WrongTypeException will always be thrown if your object implements the ICreateObject interface, but does not create the expected object type as the result value.

Here’s an example for this:

    /// <summary>

    /// This class creates the wrong object type and causes the WrongTypeException

    /// </summary>

    public class WrongType : BaseVO, ICreateObject

    {

        private int number;

 

        /// <summary>

        /// Gets or sets the number.

        /// </summary>

        /// <value>The number.</value>

        [PropertyName("IntNumber")]

        public int Number

        {

            get { return number; }

            set { number = value; }

        }

 

        /// <summary>

        /// Creates the new object.

        /// </summary>

        /// <returns></returns>

        public IValueObject CreateNewObject()

        {

            return new NullValue();

        }

    }

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>