The Labs \ Source Viewer \ SSCLI \ System.Xml.Serialization.Configuration \ DateTimeSerializationMode

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DateTimeSerializationSection.cs" company="Microsoft Corporation">
  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.Configuration
  17. {
  18.     using System;
  19.     using System.Configuration;
  20.     using System.ComponentModel;
  21.     using System.Globalization;
  22.     using System.Reflection;
  23.    
  24.     public sealed class DateTimeSerializationSection : ConfigurationSection
  25.     {
  26.         public enum DateTimeSerializationMode
  27.         {
  28.             Default = 0,
  29.             Roundtrip = 1,
  30.             Local = 2
  31.         }
  32.        
  33.         public DateTimeSerializationSection()
  34.         {
  35.             this.properties.Add(this.mode);
  36.         }
  37.        
  38.         protected override ConfigurationPropertyCollection Properties {
  39.             get { return this.properties; }
  40.         }
  41.        
  42.         [ConfigurationProperty(ConfigurationStrings.Mode, DefaultValue = DateTimeSerializationMode.Roundtrip)]
  43.         public DateTimeSerializationMode Mode {
  44.             get { return (DateTimeSerializationMode)this[this.mode]; }
  45.             set { this[this.mode] = value; }
  46.         }
  47.        
  48.         ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
  49.        
  50.         // Supply a type converter, even though it's a plain type converter, to get around ConfigurationProperty's internal
  51.         // Enum conversion routine. The internal one is case-sensitive, we want this to be case-insensitive.
  52.         readonly ConfigurationProperty mode = new ConfigurationProperty(ConfigurationStrings.Mode, typeof(DateTimeSerializationMode), DateTimeSerializationMode.Roundtrip, new EnumConverter(typeof(DateTimeSerializationMode)), null, ConfigurationPropertyOptions.None);
  53.        
  54.     }
  55.    
  56. }

Developer Fusion