FileUploadConfig.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Configuration;
  6. namespace EMIS.ViewModel
  7. {
  8. public class FileUploadConfig : IConfigurationSectionHandler
  9. {
  10. public FileUploadConfig()
  11. {
  12. ServiceTypes = new Dictionary<string, string>();
  13. }
  14. public Dictionary<string, string> ServiceTypes { get; set; }
  15. public object Create(object parent, object configContext, System.Xml.XmlNode section)
  16. {
  17. FileUploadConfig config = new FileUploadConfig();
  18. var sectionConfigList = section.SelectNodes("add");
  19. for (int i = 0; i < sectionConfigList.Count; i++)
  20. {
  21. var sectionConfig = sectionConfigList.Item(i);
  22. if (sectionConfig != null && sectionConfig.Attributes != null)
  23. {
  24. var name = sectionConfig.Attributes["name"];
  25. var value = sectionConfig.Attributes["value"];
  26. if (name != null && value != null)
  27. {
  28. if (name.Value != null && value.Value != null)
  29. {
  30. config.ServiceTypes.Add(name.Value, value.Value);
  31. }
  32. }
  33. }
  34. }
  35. return config;
  36. }
  37. }
  38. }