Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / BooleanConverter.cs / 1305376 / BooleanConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel { using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public class BooleanConverter : TypeConverter { private static StandardValuesCollection values; ///Provides a type converter to convert /// Boolean objects to and from various other representations. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } ///Gets a value indicating whether this converter can /// convert an object in the given source type to a Boolean object using the /// specified context. ////// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); try { return Boolean.Parse(text); } catch (FormatException e) { throw new FormatException(SR.GetString(SR.ConvertInvalidPrimitive, (string)value, "Boolean"), e); } } return base.ConvertFrom(context, culture, value); } ///Converts the given value /// object to a Boolean object. ////// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { values = new StandardValuesCollection(new object[] {true, false}); } return values; } ///Gets a collection of standard values /// for the Boolean data type. ////// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } ///Gets a value indicating whether the list of standard values returned from /// ///is an exclusive list. /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //Gets a value indicating whether this object supports a standard set of values /// that can be picked from a list. ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel { using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Runtime.Serialization.Formatters; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public class BooleanConverter : TypeConverter { private static StandardValuesCollection values; ///Provides a type converter to convert /// Boolean objects to and from various other representations. ////// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } ///Gets a value indicating whether this converter can /// convert an object in the given source type to a Boolean object using the /// specified context. ////// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); try { return Boolean.Parse(text); } catch (FormatException e) { throw new FormatException(SR.GetString(SR.ConvertInvalidPrimitive, (string)value, "Boolean"), e); } } return base.ConvertFrom(context, culture, value); } ///Converts the given value /// object to a Boolean object. ////// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { values = new StandardValuesCollection(new object[] {true, false}); } return values; } ///Gets a collection of standard values /// for the Boolean data type. ////// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } ///Gets a value indicating whether the list of standard values returned from /// ///is an exclusive list. /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.Gets a value indicating whether this object supports a standard set of values /// that can be picked from a list. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GeometryHitTestParameters.cs
- _StreamFramer.cs
- BrowsableAttribute.cs
- XslException.cs
- CustomSignedXml.cs
- TextViewBase.cs
- DataGridViewHitTestInfo.cs
- IList.cs
- LocalizableAttribute.cs
- SharedPersonalizationStateInfo.cs
- UInt64Converter.cs
- TreeViewTemplateSelector.cs
- ObjectManager.cs
- Icon.cs
- IsolatedStorageFilePermission.cs
- ColorConverter.cs
- DataReaderContainer.cs
- StrokeDescriptor.cs
- DeflateEmulationStream.cs
- WebPartMenuStyle.cs
- MaterialCollection.cs
- HashAlgorithm.cs
- TreeWalker.cs
- XmlReflectionImporter.cs
- SimpleExpression.cs
- TimeSpanStorage.cs
- ParagraphResult.cs
- Win32MouseDevice.cs
- StreamWithDictionary.cs
- IntSecurity.cs
- FileChangesMonitor.cs
- Border.cs
- PropertyRef.cs
- XslAstAnalyzer.cs
- Visual3D.cs
- UnmanagedHandle.cs
- ProfileInfo.cs
- ImpersonationContext.cs
- UnsafeNativeMethods.cs
- TextServicesDisplayAttribute.cs
- ValidatingReaderNodeData.cs
- AssemblyInfo.cs
- DesignerAttribute.cs
- DbProviderConfigurationHandler.cs
- GetLastErrorDetailsRequest.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- WmlCommandAdapter.cs
- MetafileHeaderWmf.cs
- InkCanvasSelection.cs
- TreeIterators.cs
- CookielessHelper.cs
- LocatorGroup.cs
- ConnectorSelectionGlyph.cs
- LicenseManager.cs
- SiteIdentityPermission.cs
- RegexCaptureCollection.cs
- BitmapFrame.cs
- ListViewPagedDataSource.cs
- RadioButtonList.cs
- Stack.cs
- AnnotationMap.cs
- RsaSecurityToken.cs
- Int64Storage.cs
- DataGrid.cs
- FuncTypeConverter.cs
- InternalCache.cs
- SmiGettersStream.cs
- SQLChars.cs
- PrimarySelectionAdorner.cs
- OwnerDrawPropertyBag.cs
- CLSCompliantAttribute.cs
- WrapperEqualityComparer.cs
- BufferedStream.cs
- BuiltInExpr.cs
- XmlSchemaException.cs
- SineEase.cs
- IISUnsafeMethods.cs
- WebBrowserDocumentCompletedEventHandler.cs
- ToolStripGrip.cs
- AttachmentCollection.cs
- DataTemplateSelector.cs
- SourceFileBuildProvider.cs
- TextParagraphCache.cs
- TypedReference.cs
- TdsValueSetter.cs
- ToolStripItemEventArgs.cs
- OdbcConnection.cs
- DateTime.cs
- RequestCacheManager.cs
- LineBreakRecord.cs
- CodeExporter.cs
- PermissionAttributes.cs
- WebPartTracker.cs
- ToolStripItem.cs
- TextRange.cs
- TryCatchDesigner.xaml.cs
- _HelperAsyncResults.cs
- BufferedStream.cs
- Pair.cs
- ProcessModelInfo.cs