Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Runtime / Serialization / FormatterConverter.cs / 1 / FormatterConverter.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: FormatterConverter ** ** ** Purpose: A base implementation of the IFormatterConverter ** interface that uses the Convert class and the ** IConvertible interface. ** ** ============================================================*/ namespace System.Runtime.Serialization { using System; using System.Globalization; [System.Runtime.InteropServices.ComVisible(true)] public class FormatterConverter : IFormatterConverter { public FormatterConverter() { } public Object Convert(Object value, Type type) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ChangeType(value, type, CultureInfo.InvariantCulture); } public Object Convert(Object value, TypeCode typeCode) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture); } public bool ToBoolean(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToBoolean(value, CultureInfo.InvariantCulture); } public char ToChar(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToChar(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public sbyte ToSByte(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToSByte(value, CultureInfo.InvariantCulture); } public byte ToByte(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToByte(value, CultureInfo.InvariantCulture); } public short ToInt16(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToInt16(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public ushort ToUInt16(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToUInt16(value, CultureInfo.InvariantCulture); } public int ToInt32(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToInt32(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public uint ToUInt32(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToUInt32(value, CultureInfo.InvariantCulture); } public long ToInt64(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToInt64(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public ulong ToUInt64(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToUInt64(value, CultureInfo.InvariantCulture); } public float ToSingle(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToSingle(value, CultureInfo.InvariantCulture); } public double ToDouble(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToDouble(value, CultureInfo.InvariantCulture); } public Decimal ToDecimal(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToDecimal(value, CultureInfo.InvariantCulture); } public DateTime ToDateTime(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToDateTime(value, CultureInfo.InvariantCulture); } public String ToString(Object value) { if (value==null) { throw new ArgumentNullException("value"); } return System.Convert.ToString(value, CultureInfo.InvariantCulture); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DateTimeFormatInfo.cs
- ToolStripItemCollection.cs
- PolicyUnit.cs
- ApplicationId.cs
- CompilerErrorCollection.cs
- COM2IDispatchConverter.cs
- LayoutManager.cs
- JulianCalendar.cs
- CatalogPartCollection.cs
- Operator.cs
- DataPagerFieldCollection.cs
- PeerNameRecord.cs
- DataRecordInternal.cs
- ConnectionManager.cs
- GuidelineCollection.cs
- SchemaImporterExtension.cs
- ObjectReaderCompiler.cs
- AnnotationHighlightLayer.cs
- WinFormsUtils.cs
- SmtpCommands.cs
- ProvidePropertyAttribute.cs
- BamlTreeUpdater.cs
- WebPartConnectionsConfigureVerb.cs
- MsdtcWrapper.cs
- StickyNoteHelper.cs
- AppearanceEditorPart.cs
- _UriSyntax.cs
- DbQueryCommandTree.cs
- ValueProviderWrapper.cs
- RuleConditionDialog.cs
- GroupItemAutomationPeer.cs
- X509ScopedServiceCertificateElementCollection.cs
- ViewDesigner.cs
- HybridObjectCache.cs
- PropertyConverter.cs
- HwndAppCommandInputProvider.cs
- MethodAccessException.cs
- TypeResolver.cs
- HWStack.cs
- DbConnectionOptions.cs
- SolidColorBrush.cs
- ExplicitDiscriminatorMap.cs
- SendKeys.cs
- altserialization.cs
- ExceptionCollection.cs
- ComponentCache.cs
- VisualBasicDesignerHelper.cs
- RectangleGeometry.cs
- XmlRawWriterWrapper.cs
- KeyEventArgs.cs
- ConfigurationConverterBase.cs
- VisualTreeUtils.cs
- FixedSOMImage.cs
- AttachInfo.cs
- NameValueCollection.cs
- ServiceMetadataPublishingElement.cs
- XmlReaderSettings.cs
- IPGlobalProperties.cs
- ProbeDuplex11AsyncResult.cs
- Debug.cs
- SqlUdtInfo.cs
- ExecutedRoutedEventArgs.cs
- ParallelTimeline.cs
- OdbcHandle.cs
- SiteOfOriginContainer.cs
- SelectionEditingBehavior.cs
- ObjectReaderCompiler.cs
- Matrix.cs
- TextBlockAutomationPeer.cs
- IncrementalReadDecoders.cs
- ColumnPropertiesGroup.cs
- RegexCompiler.cs
- OutOfMemoryException.cs
- ScalarOps.cs
- UnmanagedBitmapWrapper.cs
- PropertyChangedEventManager.cs
- SecurityPermission.cs
- WebPartConnectionsCancelVerb.cs
- AssociationType.cs
- WebBrowserSiteBase.cs
- TypographyProperties.cs
- ObjectSecurityT.cs
- ConfigurationPropertyAttribute.cs
- EventProviderClassic.cs
- TimeoutValidationAttribute.cs
- CallbackHandler.cs
- HttpCapabilitiesBase.cs
- XPathBinder.cs
- OwnerDrawPropertyBag.cs
- OSFeature.cs
- XamlReaderHelper.cs
- OpacityConverter.cs
- Vertex.cs
- HtmlSelect.cs
- BindingSource.cs
- WebPartEventArgs.cs
- DynamicRendererThreadManager.cs
- TemplateBindingExtensionConverter.cs
- Parser.cs
- Listen.cs