The Labs \ Source Viewer \ SSCLI \ System.Xml.Serialization \ XmlElementAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlElementAttribute.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. // <owner current="true" primary="true">ElenaK</owner>
  15. //------------------------------------------------------------------------------
  16. namespace System.Xml.Serialization
  17. {
  18.     using System;
  19.     using System.Xml.Schema;
  20.    
  21.     /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute"]/*' />
  22.     /// <devdoc>
  23.     /// <para>[To be supplied.]</para>
  24.     /// </devdoc>
  25.     [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
  26.     public class XmlElementAttribute : System.Attribute
  27.     {
  28.         string elementName;
  29.         Type type;
  30.         string ns;
  31.         string dataType;
  32.         bool nullable;
  33.         bool nullableSpecified;
  34.         XmlSchemaForm form = XmlSchemaForm.None;
  35.         int order = -1;
  36.        
  37.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute"]/*' />
  38.         /// <devdoc>
  39.         /// <para>[To be supplied.]</para>
  40.         /// </devdoc>
  41.         public XmlElementAttribute()
  42.         {
  43.         }
  44.        
  45.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute1"]/*' />
  46.         /// <devdoc>
  47.         /// <para>[To be supplied.]</para>
  48.         /// </devdoc>
  49.         public XmlElementAttribute(string elementName)
  50.         {
  51.             this.elementName = elementName;
  52.         }
  53.        
  54.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute2"]/*' />
  55.         /// <devdoc>
  56.         /// <para>[To be supplied.]</para>
  57.         /// </devdoc>
  58.         public XmlElementAttribute(Type type)
  59.         {
  60.             this.type = type;
  61.         }
  62.        
  63.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.XmlElementAttribute3"]/*' />
  64.         /// <devdoc>
  65.         /// <para>[To be supplied.]</para>
  66.         /// </devdoc>
  67.         public XmlElementAttribute(string elementName, Type type)
  68.         {
  69.             this.elementName = elementName;
  70.             this.type = type;
  71.         }
  72.        
  73.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Type"]/*' />
  74.         /// <devdoc>
  75.         /// <para>[To be supplied.]</para>
  76.         /// </devdoc>
  77.         public Type Type {
  78.             get { return type; }
  79.             set { type = value; }
  80.         }
  81.        
  82.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.ElementName"]/*' />
  83.         /// <devdoc>
  84.         /// <para>[To be supplied.]</para>
  85.         /// </devdoc>
  86.         public string ElementName {
  87.             get { return elementName == null ? string.Empty : elementName; }
  88.             set { elementName = value; }
  89.         }
  90.        
  91.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Namespace"]/*' />
  92.         /// <devdoc>
  93.         /// <para>[To be supplied.]</para>
  94.         /// </devdoc>
  95.         public string Namespace {
  96.             get { return ns; }
  97.             set { ns = value; }
  98.         }
  99.        
  100.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.DataType"]/*' />
  101.         /// <devdoc>
  102.         /// <para>[To be supplied.]</para>
  103.         /// </devdoc>
  104.         public string DataType {
  105.             get { return dataType == null ? string.Empty : dataType; }
  106.             set { dataType = value; }
  107.         }
  108.        
  109.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.IsNullable"]/*' />
  110.         /// <devdoc>
  111.         /// <para>[To be supplied.]</para>
  112.         /// </devdoc>
  113.         public bool IsNullable {
  114.             get { return nullable; }
  115.             set {
  116.                 nullable = value;
  117.                 nullableSpecified = true;
  118.             }
  119.         }
  120.        
  121.         internal bool IsNullableSpecified {
  122.             get { return nullableSpecified; }
  123.         }
  124.        
  125.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Form"]/*' />
  126.         /// <devdoc>
  127.         /// <para>[To be supplied.]</para>
  128.         /// </devdoc>
  129.         public XmlSchemaForm Form {
  130.             get { return form; }
  131.             set { form = value; }
  132.         }
  133.        
  134.         /// <include file='doc\XmlElementAttribute.uex' path='docs/doc[@for="XmlElementAttribute.Order"]/*' />
  135.         /// <devdoc>
  136.         /// <para>[To be supplied.]</para>
  137.         /// </devdoc>
  138.         public int Order {
  139.             get { return order; }
  140.             set {
  141.                 if (value < 0)
  142.                     throw new ArgumentException(Res.GetString(Res.XmlDisallowNegativeValues), "Order");
  143.                 order = value;
  144.             }
  145.         }
  146.     }
  147. }

Developer Fusion