ConfigurationHandler.cs 944 B

1234567891011121314151617181920212223242526272829303132333435
  1. #if NET45
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Configuration;
  5. using System.Xml;
  6. namespace PaySharp.Core
  7. {
  8. public class ConfigurationHandler : IConfigurationSectionHandler
  9. {
  10. public object Create(object parent, object configContext, XmlNode section)
  11. {
  12. var list = new List<Hashtable>();
  13. foreach (XmlNode child in section.ChildNodes)
  14. {
  15. var hashtable = new Hashtable();
  16. if (child.Attributes["gatewayUrl"] != null)
  17. {
  18. hashtable.Add("gatewayUrl", child.Attributes["gatewayUrl"].Value);
  19. }
  20. foreach (XmlNode grandChild in child.ChildNodes)
  21. {
  22. hashtable.Add(grandChild.Name, grandChild.InnerText);
  23. }
  24. list.Add(hashtable);
  25. }
  26. return list;
  27. }
  28. }
  29. }
  30. #endif