XmlElementAttribute.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlElementAttribute.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">Microsoft</owner>
  6. //------------------------------------------------------------------------------
  7. namespace System.Xml.Serialization {
  8. using System;
  9. using System.Xml.Schema;
  10. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute"]/*' />
  11. /// <devdoc>
  12. /// <para>[To be supplied.]</para>
  13. /// </devdoc>
  14. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=true)]
  15. public class XmlElementAttribute : System.Attribute {
  16. string elementName;
  17. Type type;
  18. string ns;
  19. string dataType;
  20. bool nullable;
  21. bool nullableSpecified;
  22. XmlSchemaForm form = XmlSchemaForm.None;
  23. int order = -1;
  24. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute"]/*' />
  25. /// <devdoc>
  26. /// <para>[To be supplied.]</para>
  27. /// </devdoc>
  28. public XmlElementAttribute() {
  29. }
  30. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute1"]/*' />
  31. /// <devdoc>
  32. /// <para>[To be supplied.]</para>
  33. /// </devdoc>
  34. public XmlElementAttribute(string elementName) {
  35. this.elementName = elementName;
  36. }
  37. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute2"]/*' />
  38. /// <devdoc>
  39. /// <para>[To be supplied.]</para>
  40. /// </devdoc>
  41. public XmlElementAttribute(Type type) {
  42. this.type = type;
  43. }
  44. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute3"]/*' />
  45. /// <devdoc>
  46. /// <para>[To be supplied.]</para>
  47. /// </devdoc>
  48. public XmlElementAttribute(string elementName, Type type) {
  49. this.elementName = elementName;
  50. this.type = type;
  51. }
  52. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Type"]/*' />
  53. /// <devdoc>
  54. /// <para>[To be supplied.]</para>
  55. /// </devdoc>
  56. public Type Type {
  57. get { return type; }
  58. set { type = value; }
  59. }
  60. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.ElementName"]/*' />
  61. /// <devdoc>
  62. /// <para>[To be supplied.]</para>
  63. /// </devdoc>
  64. public string ElementName {
  65. get { return elementName == null ? string.Empty : elementName; }
  66. set { elementName = value; }
  67. }
  68. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Namespace"]/*' />
  69. /// <devdoc>
  70. /// <para>[To be supplied.]</para>
  71. /// </devdoc>
  72. public string Namespace {
  73. get { return ns; }
  74. set { ns = value; }
  75. }
  76. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.DataType"]/*' />
  77. /// <devdoc>
  78. /// <para>[To be supplied.]</para>
  79. /// </devdoc>
  80. public string DataType {
  81. get { return dataType == null ? string.Empty : dataType; }
  82. set { dataType = value; }
  83. }
  84. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.IsNullable"]/*' />
  85. /// <devdoc>
  86. /// <para>[To be supplied.]</para>
  87. /// </devdoc>
  88. public bool IsNullable {
  89. get { return nullable; }
  90. set {
  91. nullable = value;
  92. nullableSpecified = true;
  93. }
  94. }
  95. internal bool IsNullableSpecified {
  96. get { return nullableSpecified; }
  97. }
  98. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Form"]/*' />
  99. /// <devdoc>
  100. /// <para>[To be supplied.]</para>
  101. /// </devdoc>
  102. public XmlSchemaForm Form {
  103. get { return form; }
  104. set { form = value; }
  105. }
  106. /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Order"]/*' />
  107. /// <devdoc>
  108. /// <para>[To be supplied.]</para>
  109. /// </devdoc>
  110. public int Order {
  111. get { return order; }
  112. set {
  113. if (value < 0)
  114. throw new ArgumentException(Res.GetString(Res.XmlDisallowNegativeValues), "Order");
  115. order = value;
  116. }
  117. }
  118. }
  119. }