- zetaenterpriselibrary-source.zip
- Caching
- Common
- Core
- Data
- Logging
- References
- Direct
- ICSharpCode.SharpZipLib.dll
- log4net.dll
- NUnit
- nunit.framework.dll
- nunit.framework.extensions.dll
- nunit.mocks.dll
- Externals
- ZetaLongPaths
- ZetaLongPaths.dll
- ZetaWebControlLibrary
- de
- ZetaWebControlLib.resources.dll
- ZetaWebControlLib.dll
- Tools
- UnitTests
- Properties
- Resources
- access.mdb
- Tests
- Common
- Data
- Logging
- Tools
- UnitTests.csproj
- Web
- Windows
- Base
- Common
- Configuration
- Controls
- Dialogs
- Misc
- Properties
- Windows.csproj
- Windows.snk
- ZetaEnterpriseLibrary.sln
- zetaenterpriselibrary-bin.zip
- de
- Zeta.EnterpriseLibrary.Common.resources.dll
- Zeta.EnterpriseLibrary.Data.resources.dll
- Zeta.EnterpriseLibrary.Logging.resources.dll
- Zeta.EnterpriseLibrary.Tools.resources.dll
- Zeta.EnterpriseLibrary.Web.resources.dll
- Zeta.EnterpriseLibrary.Windows.resources.dll
- ICSharpCode.SharpZipLib.dll
- log4net.dll
- Zeta.EnterpriseLibrary.Common.dll
- Zeta.EnterpriseLibrary.Common.pdb
- Zeta.EnterpriseLibrary.Data.dll
- Zeta.EnterpriseLibrary.Data.pdb
- Zeta.EnterpriseLibrary.Logging.dll
- Zeta.EnterpriseLibrary.Logging.pdb
- Zeta.EnterpriseLibrary.Tools.dll
- Zeta.EnterpriseLibrary.Tools.pdb
- Zeta.EnterpriseLibrary.Web.dll
- Zeta.EnterpriseLibrary.Web.pdb
- Zeta.EnterpriseLibrary.Windows.dll
- Zeta.EnterpriseLibrary.Windows.pdb
- ZetaLongPaths.dll
- ZetaLongPaths.pdb
|
namespace Zeta.EnterpriseLibrary.Tools
{
using System;
using System.ComponentModel;
using System.Globalization;
using Properties;
using Common;
/// <summary>
/// BooleanLocalizedConverter uses local string for TRUE and FALSE.
/// See also http://netcode.ru/dotnet/?lang=&katID=30&skatID=264&artID=7319.
///
/// Usage:
/// Apply [TypeConverter( typeof( BooleanLocalizedConverter ) )]
/// to a property.
/// </summary>
public class BooleanLocalizedConverter : BooleanConverter
{
public override object ConvertTo(
ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType )
{
if ( value is bool && destinationType == typeof( string ) )
{
return GetLocalized( ConvertHelper.ToBoolean( value ) );
}
else if ( value is string && destinationType == typeof( string ) )
{
return GetLocalized( ConvertHelper.ToBoolean( value ) );
}
else
{
return base.ConvertTo( context, culture, value, destinationType );
}
}
public override object ConvertFrom(
ITypeDescriptorContext context,
CultureInfo culture,
object value )
{
if ( value is string )
{
var v = (string)value;
return v == Resources.SR_BooleanLocalizedConverter_True;
}
else if ( value is bool )
{
return GetLocalized( ConvertHelper.ToBoolean( value ) );
}
else
{
return base.ConvertFrom( context, culture, value );
}
}
private static object GetLocalized( bool b )
{
return b
? Resources.SR_BooleanLocalizedConverter_True
: Resources.SR_BooleanLocalizedConverter_False;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.