1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 namespace System.ServiceModel.Syndication 6 { 7 using System; 8 using System.Diagnostics; 9 using System.Globalization; 10 using System.Runtime.Serialization; 11 using System.Xml; 12 using DiagnosticUtility = System.ServiceModel.DiagnosticUtility; 13 14 [DataContract] 15 public abstract class SyndicationFeedFormatter 16 { 17 private SyndicationFeed _feed; 18 SyndicationFeedFormatter()19 protected SyndicationFeedFormatter() 20 { 21 _feed = null; 22 DateTimeParser = GetDefaultDateTimeParser(); 23 } 24 SyndicationFeedFormatter(SyndicationFeed feedToWrite)25 protected SyndicationFeedFormatter(SyndicationFeed feedToWrite) 26 { 27 if (feedToWrite == null) 28 { 29 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feedToWrite"); 30 } 31 _feed = feedToWrite; 32 DateTimeParser = GetDefaultDateTimeParser(); 33 } 34 35 public SyndicationFeed Feed 36 { 37 get 38 { 39 return _feed; 40 } 41 } 42 43 public Func<string, UriKind, string, string, Uri> UriParser { get; set; } = DefaultUriParser; 44 45 // Different DateTimeParsers are needed for Atom and Rss so can't set inline 46 public Func<string, string, string, DateTimeOffset> DateTimeParser { get; set; } 47 GetDefaultDateTimeParser()48 internal virtual Func<string, string, string, DateTimeOffset> GetDefaultDateTimeParser() 49 { 50 return NotImplementedDateTimeParser; 51 } 52 NotImplementedDateTimeParser(string dtoString, string localName, string ns)53 private DateTimeOffset NotImplementedDateTimeParser(string dtoString, string localName, string ns) 54 { 55 throw new NotImplementedException(); 56 } 57 58 public abstract string Version 59 { get; } 60 CanRead(XmlReader reader)61 public abstract bool CanRead(XmlReader reader); 62 ReadFrom(XmlReader reader)63 public abstract void ReadFrom(XmlReader reader); 64 ToString()65 public override string ToString() 66 { 67 return String.Format(CultureInfo.CurrentCulture, "{0}, SyndicationVersion={1}", this.GetType(), this.Version); 68 } 69 WriteTo(XmlWriter writer)70 public abstract void WriteTo(XmlWriter writer); 71 CreateCategory(SyndicationFeed feed)72 internal static protected SyndicationCategory CreateCategory(SyndicationFeed feed) 73 { 74 if (feed == null) 75 { 76 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 77 } 78 return GetNonNullValue<SyndicationCategory>(feed.CreateCategory(), SR.FeedCreatedNullCategory); 79 } 80 CreateCategory(SyndicationItem item)81 internal static protected SyndicationCategory CreateCategory(SyndicationItem item) 82 { 83 if (item == null) 84 { 85 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 86 } 87 return GetNonNullValue<SyndicationCategory>(item.CreateCategory(), SR.ItemCreatedNullCategory); 88 } 89 CreateItem(SyndicationFeed feed)90 internal static protected SyndicationItem CreateItem(SyndicationFeed feed) 91 { 92 if (feed == null) 93 { 94 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 95 } 96 return GetNonNullValue<SyndicationItem>(feed.CreateItem(), SR.FeedCreatedNullItem); 97 } 98 CreateLink(SyndicationFeed feed)99 internal static protected SyndicationLink CreateLink(SyndicationFeed feed) 100 { 101 if (feed == null) 102 { 103 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 104 } 105 return GetNonNullValue<SyndicationLink>(feed.CreateLink(), SR.FeedCreatedNullPerson); 106 } 107 CreateLink(SyndicationItem item)108 internal static protected SyndicationLink CreateLink(SyndicationItem item) 109 { 110 if (item == null) 111 { 112 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 113 } 114 return GetNonNullValue<SyndicationLink>(item.CreateLink(), SR.ItemCreatedNullPerson); 115 } 116 CreatePerson(SyndicationFeed feed)117 internal static protected SyndicationPerson CreatePerson(SyndicationFeed feed) 118 { 119 if (feed == null) 120 { 121 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 122 } 123 return GetNonNullValue<SyndicationPerson>(feed.CreatePerson(), SR.FeedCreatedNullPerson); 124 } 125 CreatePerson(SyndicationItem item)126 internal static protected SyndicationPerson CreatePerson(SyndicationItem item) 127 { 128 if (item == null) 129 { 130 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 131 } 132 return GetNonNullValue<SyndicationPerson>(item.CreatePerson(), SR.ItemCreatedNullPerson); 133 } 134 LoadElementExtensions(XmlReader reader, SyndicationFeed feed, int maxExtensionSize)135 internal static protected void LoadElementExtensions(XmlReader reader, SyndicationFeed feed, int maxExtensionSize) 136 { 137 if (feed == null) 138 { 139 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 140 } 141 feed.LoadElementExtensions(reader, maxExtensionSize); 142 } 143 LoadElementExtensions(XmlReader reader, SyndicationItem item, int maxExtensionSize)144 internal static protected void LoadElementExtensions(XmlReader reader, SyndicationItem item, int maxExtensionSize) 145 { 146 if (item == null) 147 { 148 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 149 } 150 item.LoadElementExtensions(reader, maxExtensionSize); 151 } 152 LoadElementExtensions(XmlReader reader, SyndicationCategory category, int maxExtensionSize)153 internal static protected void LoadElementExtensions(XmlReader reader, SyndicationCategory category, int maxExtensionSize) 154 { 155 if (category == null) 156 { 157 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 158 } 159 category.LoadElementExtensions(reader, maxExtensionSize); 160 } 161 LoadElementExtensions(XmlReader reader, SyndicationLink link, int maxExtensionSize)162 internal static protected void LoadElementExtensions(XmlReader reader, SyndicationLink link, int maxExtensionSize) 163 { 164 if (link == null) 165 { 166 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 167 } 168 link.LoadElementExtensions(reader, maxExtensionSize); 169 } 170 LoadElementExtensions(XmlReader reader, SyndicationPerson person, int maxExtensionSize)171 internal static protected void LoadElementExtensions(XmlReader reader, SyndicationPerson person, int maxExtensionSize) 172 { 173 if (person == null) 174 { 175 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 176 } 177 person.LoadElementExtensions(reader, maxExtensionSize); 178 } 179 TryParseAttribute(string name, string ns, string value, SyndicationFeed feed, string version)180 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationFeed feed, string version) 181 { 182 if (feed == null) 183 { 184 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 185 } 186 if (FeedUtils.IsXmlns(name, ns)) 187 { 188 return true; 189 } 190 return feed.TryParseAttribute(name, ns, value, version); 191 } 192 TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version)193 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationItem item, string version) 194 { 195 if (item == null) 196 { 197 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 198 } 199 if (FeedUtils.IsXmlns(name, ns)) 200 { 201 return true; 202 } 203 return item.TryParseAttribute(name, ns, value, version); 204 } 205 TryParseAttribute(string name, string ns, string value, SyndicationCategory category, string version)206 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationCategory category, string version) 207 { 208 if (category == null) 209 { 210 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 211 } 212 if (FeedUtils.IsXmlns(name, ns)) 213 { 214 return true; 215 } 216 return category.TryParseAttribute(name, ns, value, version); 217 } 218 TryParseAttribute(string name, string ns, string value, SyndicationLink link, string version)219 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationLink link, string version) 220 { 221 if (link == null) 222 { 223 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 224 } 225 if (FeedUtils.IsXmlns(name, ns)) 226 { 227 return true; 228 } 229 return link.TryParseAttribute(name, ns, value, version); 230 } 231 TryParseAttribute(string name, string ns, string value, SyndicationPerson person, string version)232 internal static protected bool TryParseAttribute(string name, string ns, string value, SyndicationPerson person, string version) 233 { 234 if (person == null) 235 { 236 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 237 } 238 if (FeedUtils.IsXmlns(name, ns)) 239 { 240 return true; 241 } 242 return person.TryParseAttribute(name, ns, value, version); 243 } 244 TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content)245 internal static protected bool TryParseContent(XmlReader reader, SyndicationItem item, string contentType, string version, out SyndicationContent content) 246 { 247 return item.TryParseContent(reader, contentType, version, out content); 248 } 249 TryParseElement(XmlReader reader, SyndicationFeed feed, string version)250 internal static protected bool TryParseElement(XmlReader reader, SyndicationFeed feed, string version) 251 { 252 if (feed == null) 253 { 254 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 255 } 256 return feed.TryParseElement(reader, version); 257 } 258 TryParseElement(XmlReader reader, SyndicationItem item, string version)259 internal static protected bool TryParseElement(XmlReader reader, SyndicationItem item, string version) 260 { 261 if (item == null) 262 { 263 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 264 } 265 return item.TryParseElement(reader, version); 266 } 267 TryParseElement(XmlReader reader, SyndicationCategory category, string version)268 internal static protected bool TryParseElement(XmlReader reader, SyndicationCategory category, string version) 269 { 270 if (category == null) 271 { 272 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 273 } 274 return category.TryParseElement(reader, version); 275 } 276 TryParseElement(XmlReader reader, SyndicationLink link, string version)277 internal static protected bool TryParseElement(XmlReader reader, SyndicationLink link, string version) 278 { 279 if (link == null) 280 { 281 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 282 } 283 return link.TryParseElement(reader, version); 284 } 285 TryParseElement(XmlReader reader, SyndicationPerson person, string version)286 internal static protected bool TryParseElement(XmlReader reader, SyndicationPerson person, string version) 287 { 288 if (person == null) 289 { 290 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 291 } 292 return person.TryParseElement(reader, version); 293 } 294 WriteAttributeExtensions(XmlWriter writer, SyndicationFeed feed, string version)295 internal static protected void WriteAttributeExtensions(XmlWriter writer, SyndicationFeed feed, string version) 296 { 297 if (feed == null) 298 { 299 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 300 } 301 feed.WriteAttributeExtensions(writer, version); 302 } 303 WriteAttributeExtensions(XmlWriter writer, SyndicationItem item, string version)304 internal static protected void WriteAttributeExtensions(XmlWriter writer, SyndicationItem item, string version) 305 { 306 if (item == null) 307 { 308 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 309 } 310 item.WriteAttributeExtensions(writer, version); 311 } 312 WriteAttributeExtensions(XmlWriter writer, SyndicationCategory category, string version)313 internal static protected void WriteAttributeExtensions(XmlWriter writer, SyndicationCategory category, string version) 314 { 315 if (category == null) 316 { 317 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 318 } 319 category.WriteAttributeExtensions(writer, version); 320 } 321 WriteAttributeExtensions(XmlWriter writer, SyndicationLink link, string version)322 internal static protected void WriteAttributeExtensions(XmlWriter writer, SyndicationLink link, string version) 323 { 324 if (link == null) 325 { 326 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 327 } 328 link.WriteAttributeExtensions(writer, version); 329 } 330 WriteAttributeExtensions(XmlWriter writer, SyndicationPerson person, string version)331 internal static protected void WriteAttributeExtensions(XmlWriter writer, SyndicationPerson person, string version) 332 { 333 if (person == null) 334 { 335 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 336 } 337 person.WriteAttributeExtensions(writer, version); 338 } 339 WriteElementExtensions(XmlWriter writer, SyndicationFeed feed, string version)340 internal static protected void WriteElementExtensions(XmlWriter writer, SyndicationFeed feed, string version) 341 { 342 if (feed == null) 343 { 344 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 345 } 346 feed.WriteElementExtensions(writer, version); 347 } 348 WriteElementExtensions(XmlWriter writer, SyndicationItem item, string version)349 internal static protected void WriteElementExtensions(XmlWriter writer, SyndicationItem item, string version) 350 { 351 if (item == null) 352 { 353 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 354 } 355 item.WriteElementExtensions(writer, version); 356 } 357 WriteElementExtensions(XmlWriter writer, SyndicationCategory category, string version)358 internal static protected void WriteElementExtensions(XmlWriter writer, SyndicationCategory category, string version) 359 { 360 if (category == null) 361 { 362 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 363 } 364 category.WriteElementExtensions(writer, version); 365 } 366 WriteElementExtensions(XmlWriter writer, SyndicationLink link, string version)367 internal static protected void WriteElementExtensions(XmlWriter writer, SyndicationLink link, string version) 368 { 369 if (link == null) 370 { 371 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 372 } 373 link.WriteElementExtensions(writer, version); 374 } 375 WriteElementExtensions(XmlWriter writer, SyndicationPerson person, string version)376 internal static protected void WriteElementExtensions(XmlWriter writer, SyndicationPerson person, string version) 377 { 378 if (person == null) 379 { 380 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 381 } 382 person.WriteElementExtensions(writer, version); 383 } 384 SetFeed(SyndicationFeed feed)385 internal protected virtual void SetFeed(SyndicationFeed feed) 386 { 387 if (feed == null) 388 { 389 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 390 } 391 _feed = feed; 392 } 393 DateFromString(string dateTimeString, XmlReader reader)394 internal DateTimeOffset DateFromString(string dateTimeString, XmlReader reader) 395 { 396 try 397 { 398 return DateTimeParser(dateTimeString, reader.LocalName, reader.NamespaceURI); 399 } 400 catch (FormatException e) 401 { 402 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( 403 new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDateTime), e)); 404 } 405 } 406 DefaultUriParser(string value, UriKind kind, string localName, string ns)407 private static Uri DefaultUriParser(string value, UriKind kind, string localName, string ns) 408 { 409 return new Uri(value, kind); 410 } 411 CloseBuffer(XmlBuffer buffer, XmlDictionaryWriter extWriter)412 internal static void CloseBuffer(XmlBuffer buffer, XmlDictionaryWriter extWriter) 413 { 414 if (buffer == null) 415 { 416 return; 417 } 418 extWriter.WriteEndElement(); 419 buffer.CloseSection(); 420 buffer.Close(); 421 } 422 CreateBufferIfRequiredAndWriteNode(ref XmlBuffer buffer, ref XmlDictionaryWriter extWriter, XmlReader reader, int maxExtensionSize)423 internal static void CreateBufferIfRequiredAndWriteNode(ref XmlBuffer buffer, ref XmlDictionaryWriter extWriter, XmlReader reader, int maxExtensionSize) 424 { 425 if (buffer == null) 426 { 427 buffer = new XmlBuffer(maxExtensionSize); 428 extWriter = buffer.OpenSection(XmlDictionaryReaderQuotas.Max); 429 extWriter.WriteStartElement(Rss20Constants.ExtensionWrapperTag); 430 } 431 extWriter.WriteNode(reader, false); 432 } 433 CreateFeedInstance(Type feedType)434 internal static SyndicationFeed CreateFeedInstance(Type feedType) 435 { 436 if (feedType.Equals(typeof(SyndicationFeed))) 437 { 438 return new SyndicationFeed(); 439 } 440 else 441 { 442 return (SyndicationFeed)Activator.CreateInstance(feedType); 443 } 444 } 445 LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationFeed feed)446 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationFeed feed) 447 { 448 if (feed == null) 449 { 450 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("feed"); 451 } 452 CloseBuffer(buffer, writer); 453 feed.LoadElementExtensions(buffer); 454 } 455 LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationItem item)456 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationItem item) 457 { 458 if (item == null) 459 { 460 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item"); 461 } 462 CloseBuffer(buffer, writer); 463 item.LoadElementExtensions(buffer); 464 } 465 LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationCategory category)466 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationCategory category) 467 { 468 if (category == null) 469 { 470 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("category"); 471 } 472 CloseBuffer(buffer, writer); 473 category.LoadElementExtensions(buffer); 474 } 475 LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationLink link)476 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationLink link) 477 { 478 if (link == null) 479 { 480 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("link"); 481 } 482 CloseBuffer(buffer, writer); 483 link.LoadElementExtensions(buffer); 484 } 485 LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationPerson person)486 internal static void LoadElementExtensions(XmlBuffer buffer, XmlDictionaryWriter writer, SyndicationPerson person) 487 { 488 if (person == null) 489 { 490 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("person"); 491 } 492 CloseBuffer(buffer, writer); 493 person.LoadElementExtensions(buffer); 494 } 495 MoveToStartElement(XmlReader reader)496 internal static void MoveToStartElement(XmlReader reader) 497 { 498 Debug.Assert(reader != null, "reader != null"); 499 if (!reader.IsStartElement()) 500 { 501 XmlExceptionHelper.ThrowStartElementExpected(XmlDictionaryReader.CreateDictionaryReader(reader)); 502 } 503 } 504 TraceFeedReadBegin()505 internal static void TraceFeedReadBegin() 506 { 507 } 508 TraceFeedReadEnd()509 internal static void TraceFeedReadEnd() 510 { 511 } 512 TraceFeedWriteBegin()513 internal static void TraceFeedWriteBegin() 514 { 515 } 516 TraceFeedWriteEnd()517 internal static void TraceFeedWriteEnd() 518 { 519 } 520 TraceItemReadBegin()521 internal static void TraceItemReadBegin() 522 { 523 } 524 TraceItemReadEnd()525 internal static void TraceItemReadEnd() 526 { 527 } 528 TraceItemWriteBegin()529 internal static void TraceItemWriteBegin() 530 { 531 } 532 TraceItemWriteEnd()533 internal static void TraceItemWriteEnd() 534 { 535 } 536 TraceSyndicationElementIgnoredOnRead(XmlReader reader)537 internal static void TraceSyndicationElementIgnoredOnRead(XmlReader reader) 538 { 539 } 540 CreateFeedInstance()541 protected abstract SyndicationFeed CreateFeedInstance(); 542 GetNonNullValue(T value, string errorMsg)543 private static T GetNonNullValue<T>(T value, string errorMsg) 544 { 545 if (value == null) 546 { 547 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(errorMsg))); 548 } 549 return value; 550 } 551 552 private static class XmlExceptionHelper 553 { ThrowXmlException(XmlDictionaryReader reader, string res, string arg1)554 private static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1) 555 { 556 string s = SR.Format(res, arg1); 557 IXmlLineInfo lineInfo = reader as IXmlLineInfo; 558 if (lineInfo != null && lineInfo.HasLineInfo()) 559 { 560 s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); 561 } 562 563 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); 564 } 565 GetName(string prefix, string localName)566 private static string GetName(string prefix, string localName) 567 { 568 if (prefix.Length == 0) 569 return localName; 570 else 571 return string.Concat(prefix, ":", localName); 572 } 573 GetWhatWasFound(XmlDictionaryReader reader)574 private static string GetWhatWasFound(XmlDictionaryReader reader) 575 { 576 if (reader.EOF) 577 return SR.Format(SR.XmlFoundEndOfFile); 578 switch (reader.NodeType) 579 { 580 case XmlNodeType.Element: 581 return SR.Format(SR.XmlFoundElement, GetName(reader.Prefix, reader.LocalName), reader.NamespaceURI); 582 case XmlNodeType.EndElement: 583 return SR.Format(SR.XmlFoundEndElement, GetName(reader.Prefix, reader.LocalName), reader.NamespaceURI); 584 case XmlNodeType.Text: 585 case XmlNodeType.Whitespace: 586 case XmlNodeType.SignificantWhitespace: 587 return SR.Format(SR.XmlFoundText, reader.Value); 588 case XmlNodeType.Comment: 589 return SR.Format(SR.XmlFoundComment, reader.Value); 590 case XmlNodeType.CDATA: 591 return SR.Format(SR.XmlFoundCData, reader.Value); 592 } 593 return SR.Format(SR.XmlFoundNodeType, reader.NodeType); 594 } 595 ThrowStartElementExpected(XmlDictionaryReader reader)596 static public void ThrowStartElementExpected(XmlDictionaryReader reader) 597 { 598 ThrowXmlException(reader, SR.XmlStartElementExpected, GetWhatWasFound(reader)); 599 } 600 } 601 } 602 } 603