ForecourtControlXml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. namespace Wayne.ForecourtControl
  3. {
  4. /// <summary>
  5. /// Xml serialization support class.
  6. /// </summary>
  7. public static class ForecourtControlXml
  8. {
  9. #region Fields
  10. private static System.Xml.Schema.XmlSchema schema;
  11. #endregion
  12. #region Properties
  13. /// <summary>
  14. /// Namespace for Forecourt control.
  15. /// </summary>
  16. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", MessageId = "Member")]
  17. public const string Ns = "http://www.wayne.com/2006-08-14/ForecourtControl.xsd";
  18. #endregion
  19. #region Methods
  20. /// <summary>
  21. /// Adds the internal schemas to an xml schema set object.
  22. /// </summary>
  23. /// <param name="xmlSchemaSet"></param>
  24. public static void AddSchemas(System.Xml.Schema.XmlSchemaSet xmlSchemaSet)
  25. {
  26. schema = null; // MLA: DON'T CACHE
  27. if (schema == null)
  28. {
  29. string schemaName = "Wayne.ForecourtControl.ForecourtControl.xsd";
  30. using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(schemaName))
  31. {
  32. schema = System.Xml.Schema.XmlSchema.Read(stream, null);
  33. }
  34. if (schema == null)
  35. throw new NullReferenceException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Embedded resource XML-schema \"{0}\" not found!", ForecourtControlXml.Ns));
  36. }
  37. if (xmlSchemaSet != null)
  38. {
  39. if (!xmlSchemaSet.Contains(schema.TargetNamespace))
  40. xmlSchemaSet.Add(schema);
  41. }
  42. }
  43. #endregion
  44. }
  45. }