XmlSerializerImportOptions.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Channels
  5. {
  6. using System;
  7. using System.CodeDom.Compiler;
  8. using System.CodeDom;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.Globalization;
  13. using System.IO;
  14. using System.Text;
  15. using System.ServiceModel;
  16. using System.Runtime.Serialization;
  17. using System.Xml;
  18. using System.Xml.Schema;
  19. using System.Xml.Serialization;
  20. using WsdlNS = System.Web.Services.Description;
  21. public class XmlSerializerImportOptions
  22. {
  23. CodeCompileUnit codeCompileUnit;
  24. CodeDomProvider codeProvider;
  25. string clrNamespace;
  26. WsdlNS.WebReferenceOptions webReferenceOptions;
  27. static CodeGenerationOptions defaultCodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateOrder;
  28. public XmlSerializerImportOptions()
  29. : this(new CodeCompileUnit())
  30. {
  31. }
  32. public XmlSerializerImportOptions(CodeCompileUnit codeCompileUnit)
  33. {
  34. this.codeCompileUnit = codeCompileUnit;
  35. }
  36. public CodeCompileUnit CodeCompileUnit
  37. {
  38. get
  39. {
  40. if (codeCompileUnit == null)
  41. codeCompileUnit = new CodeCompileUnit();
  42. return codeCompileUnit;
  43. }
  44. }
  45. public CodeDomProvider CodeProvider
  46. {
  47. get
  48. {
  49. if (codeProvider == null)
  50. codeProvider = CodeDomProvider.CreateProvider("C#");
  51. return codeProvider;
  52. }
  53. set { codeProvider = value; }
  54. }
  55. public string ClrNamespace
  56. {
  57. get { return clrNamespace; }
  58. set { clrNamespace = value; }
  59. }
  60. public WsdlNS.WebReferenceOptions WebReferenceOptions
  61. {
  62. get
  63. {
  64. if (webReferenceOptions == null)
  65. {
  66. webReferenceOptions = new WsdlNS.WebReferenceOptions();
  67. webReferenceOptions.CodeGenerationOptions = defaultCodeGenerationOptions;
  68. }
  69. return webReferenceOptions;
  70. }
  71. set { webReferenceOptions = value; }
  72. }
  73. }
  74. }