The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ MultilineStringConverter

  1. //------------------------------------------------------------------------------
  2. // <copyright file="MultilineStringConverter.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. //------------------------------------------------------------------------------
  15. namespace System.ComponentModel
  16. {
  17.    
  18.     using System.ComponentModel;
  19.     using System.ComponentModel.Design;
  20.     using System.Diagnostics;
  21.     using System.Globalization;
  22.     using System.Security.Permissions;
  23.    
  24.     /// <devdoc>
  25.     /// Provides a type converter to convert multiline strings to a simple string.
  26.     /// </devdoc>
  27.     [HostProtection(SharedState = true)]
  28.     [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
  29.     public class MultilineStringConverter : TypeConverter
  30.     {
  31.        
  32.         /// <devdoc>
  33.         /// Converts the given value object to the specified destination type.
  34.         /// </devdoc>
  35.         public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
  36.         {
  37.             if (destinationType == null) {
  38.                 throw new ArgumentNullException("destinationType");
  39.             }
  40.            
  41.             if (destinationType == typeof(string)) {
  42.                 if (value is string) {
  43.                     return SR.GetString(SR.MultilineStringConverterText);
  44.                 }
  45.             }
  46.            
  47.             return base.ConvertTo(context, culture, value, destinationType);
  48.         }
  49.        
  50.         /// <devdoc>
  51.         /// Gets a collection of properties for the type of array specified by the value
  52.         /// parameter using the specified context and attributes.
  53.         /// </devdoc>
  54.         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
  55.         {
  56.             return null;
  57.         }
  58.        
  59.         /// <devdoc>
  60.         /// Gets a value indicating whether this object supports properties.
  61.         /// </devdoc>
  62.         public override bool GetPropertiesSupported(ITypeDescriptorContext context)
  63.         {
  64.             return false;
  65.         }
  66.     }
  67. }

Developer Fusion