/// <summary>
        /// This method reads the specified element.
        /// </summary>
        /// <param name="pObjectToInitialize">The object to initialize</param>
        /// <param name="pParentElement">The element.</param>
        /// <param name="pSerializationContext">The serialization context.</param>
        /// <returns>The initialized object if the input object is valid.</returns>
        public virtual object Read(object pObjectToInitialize, XElement pParentElement, IXSerializationContext pSerializationContext)
        {
            object     lResult    = null;
            XAttribute lAttribute = pParentElement.Attribute(XConstants.REFERENCE_ATTRIBUTE);

            if (lAttribute != null)
            {
                try
                {
                    int lReference = Convert.ToInt32(lAttribute.Value.Trim(), CultureInfo.InvariantCulture);
                    lResult = pSerializationContext.GetObjectByReference(lReference);
                    if (lResult == null) // If ref not found in cache yet, attempt to retrieve it ourselves
                    {
                        lResult = this.AttemptReferenceRetrieval(pObjectToInitialize, pParentElement, lReference, pSerializationContext);
                    }
                }
                catch (FormatException)
                {
                    IXmlLineInfo lInfo = pParentElement;
                    pSerializationContext.PushError(new XSerializationError(XErrorType.Parsing, lInfo.LineNumber, lInfo.LinePosition, pSerializationContext.CurrentFile, string.Empty));
                }
                catch (OverflowException)
                {
                    IXmlLineInfo lInfo = pParentElement;
                    pSerializationContext.PushError(new XSerializationError(XErrorType.NumberOverflow, lInfo.LineNumber, lInfo.LinePosition, pSerializationContext.CurrentFile, string.Empty));
                }
            }

            return(lResult);
        }
 /// <summary>
 /// This method reads the specified element.
 /// </summary>
 /// <param name="pObjectToInitialize">The object to initialize</param>
 /// <param name="pParentElement">The element.</param>
 /// <param name="pSerializationContext">The serialization context.</param>
 /// <returns>The initialized object if the input object is valid.</returns>
 public virtual object Read(object pObjectToInitialize, XElement pParentElement, IXSerializationContext pSerializationContext)
 {
     XAttribute lAttribute = pParentElement.Attribute(XConstants.REFERENCE_ATTRIBUTE);
     try
     {
         int lReference = Convert.ToInt32(lAttribute.Value.Trim(), CultureInfo.InvariantCulture);
         return pSerializationContext.GetObjectByReference(lReference);
     }
     catch (FormatException)
     {
         IXmlLineInfo lInfo = pParentElement;
         pSerializationContext.PushError(new XSerializationError(XErrorType.Parsing, lInfo.LineNumber, lInfo.LinePosition, pSerializationContext.CurrentFile, string.Empty));
     }
     catch (OverflowException)
     {
         IXmlLineInfo lInfo = pParentElement;
         pSerializationContext.PushError(new XSerializationError(XErrorType.NumberOverflow, lInfo.LineNumber, lInfo.LinePosition, pSerializationContext.CurrentFile, string.Empty));
     }
     return null;
 }