/// <summary> /// Resolves the given entity token. /// </summary> /// <param name="entityToken">The entity token to resolve.</param> /// <returns>The string that is contained in the entity token.</returns> public String GetEntity(XmlEntityToken entityToken) { if (entityToken.IsNumeric) { var str = entityToken.Value; int num = 0; int basis = 1; for (int i = str.Length - 1; i >= 0; i--) { num += str[i].FromHex() * basis; basis *= 16; } return Char.ConvertFromUtf32(num); } else { var entity = _dtd.GetEntity(entityToken.Value); if (entity == null) throw new ArgumentException("Well-formedness constraint: entity declared."); return entity.NodeValue; } }
/// <summary> /// Resolves the given entity token. /// </summary> /// <param name="entityToken">The entity token to resolve.</param> /// <returns>The string that is contained in the entity token.</returns> public String GetEntity(XmlEntityToken entityToken) { if (entityToken.IsNumeric) { var num = entityToken.IsHex ? entityToken.Value.FromHex() : entityToken.Value.FromDec(); if (!num.IsValidAsCharRef()) throw Errors.Xml(ErrorCode.CharacterReferenceInvalidNumber); return Char.ConvertFromUtf32(num); } else { var entity = _dtd.GetEntity(entityToken.Value); if (entity == null) throw Errors.Xml(ErrorCode.CharacterReferenceInvalidCode); return entity.NodeValue; } }