WhiteSpaceTrimStringConverter Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts a string to its canonical format.
public ref class WhiteSpaceTrimStringConverter sealed : System::Configuration::ConfigurationConverterBase
public sealed class WhiteSpaceTrimStringConverter : System.Configuration.ConfigurationConverterBase
type WhiteSpaceTrimStringConverter = class
inherit ConfigurationConverterBase
Public NotInheritable Class WhiteSpaceTrimStringConverter
Inherits ConfigurationConverterBase
- Inheritance
Examples
The following code example shows how to apply WhiteSpaceTrimStringConverter to a custom string property FileName.
[ConfigurationProperty("fileName", DefaultValue=" default.txt ")]
[TypeConverter(typeof(WhiteSpaceTrimStringConverter))]
public String FileName
{
get
{
return (String)this["fileName"];
}
set
{
this["fileName"] = value;
}
}
<ConfigurationProperty("fileName", _
DefaultValue:=" default.txt "), _
TypeConverter(GetType(WhiteSpaceTrimStringConverter))> _
Public Property FileName() As String
Get
Return CStr(Me("fileName"))
End Get
Set(ByVal value As String)
Me("fileName") = value
End Set
End Property
The following is a configuration excerpt used by the previous example.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="CustomSection"
type="Samples.AspNet.CustomSection,
ConfigurationConverters,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"
allowDefinition="Everywhere"
allowExeDefinition="MachineToApplication"
restartOnExternalChanges="true" />
</configSections>
<CustomSection fileName="default.txt" maxIdleTime="90" timeDelay="infinite" cdStr="str0, str1" permission="Read" maxUsers="Infinite"/>
</configuration>
Remarks
This WhiteSpaceTrimStringConverter object converts between a configuration string value and its canonical representation. Canonical representation means that all white spaces are trimmed from the beginning and end of a string value.
Constructors
| Name | Description |
|---|---|
| WhiteSpaceTrimStringConverter() |
Initializes a new instance of the WhiteSpaceTrimStringConverter class. |
Methods
| Name | Description |
|---|---|
| CanConvertFrom(ITypeDescriptorContext, Type) |
Determines whether the conversion is allowed. (Inherited from ConfigurationConverterBase) |
| CanConvertTo(ITypeDescriptorContext, Type) |
Determines whether the conversion is allowed. (Inherited from ConfigurationConverterBase) |
| ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) |
Converts a String to canonical form. |
| ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type) |
Converts a String to canonical form. |