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
- DataGridViewCellPaintingEventArgs.cs
- ReflectionPermission.cs
- DetailsViewPagerRow.cs
- DispatcherProcessingDisabled.cs
- CodeSnippetCompileUnit.cs
- HotSpotCollection.cs
- TypeConverter.cs
- NotifyIcon.cs
- XhtmlBasicPanelAdapter.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- CacheAxisQuery.cs
- SamlAuthorityBinding.cs
- NamespaceInfo.cs
- DataPagerField.cs
- XmlBaseWriter.cs
- ConnectionsZone.cs
- StateMachineHelpers.cs
- InputProviderSite.cs
- WebPartDisplayModeEventArgs.cs
- securitycriticaldataClass.cs
- Vector3DAnimationUsingKeyFrames.cs
- DocumentCollection.cs
- CqlGenerator.cs
- _NativeSSPI.cs
- Behavior.cs
- OuterGlowBitmapEffect.cs
- URIFormatException.cs
- DataGridLinkButton.cs
- AnnotationResourceChangedEventArgs.cs
- WebPartConnectionCollection.cs
- BinaryParser.cs
- PointKeyFrameCollection.cs
- SamlAuthorityBinding.cs
- dbdatarecord.cs
- MsmqAppDomainProtocolHandler.cs
- VirtualDirectoryMappingCollection.cs
- PrintDocument.cs
- ReadOnlyPropertyMetadata.cs
- ActivityCompletionCallbackWrapper.cs
- Int32.cs
- StoryFragments.cs
- NullableConverter.cs
- SurrogateEncoder.cs
- HttpCookie.cs
- SectionInformation.cs
- VirtualPathUtility.cs
- StylusSystemGestureEventArgs.cs
- xmlsaver.cs
- XamlBuildProvider.cs
- RealProxy.cs
- WindowsTooltip.cs
- Win32.cs
- XmlKeywords.cs
- FileFormatException.cs
- XmlSerializableWriter.cs
- ElasticEase.cs
- TransactionScope.cs
- WrappedReader.cs
- CustomValidator.cs
- WebControlAdapter.cs
- DragStartedEventArgs.cs
- MetafileHeader.cs
- RotateTransform3D.cs
- VolatileResourceManager.cs
- HMACSHA512.cs
- DesignerTransactionCloseEvent.cs
- SqlDataSourceCache.cs
- CatalogZoneBase.cs
- WebDisplayNameAttribute.cs
- ExtensionSimplifierMarkupObject.cs
- BasePropertyDescriptor.cs
- XPathNavigator.cs
- HttpRawResponse.cs
- InvalidPipelineStoreException.cs
- TaskHelper.cs
- CodeParameterDeclarationExpression.cs
- CustomWebEventKey.cs
- Fonts.cs
- WebSysDescriptionAttribute.cs
- NameValueConfigurationCollection.cs
- RelationshipConstraintValidator.cs
- ExportFileRequest.cs
- EnlistmentTraceIdentifier.cs
- dataprotectionpermission.cs
- XmlSchemaAll.cs
- ILGenerator.cs
- AdjustableArrowCap.cs
- CodeDefaultValueExpression.cs
- VisualTreeHelper.cs
- ExpressionCopier.cs
- AsymmetricSignatureDeformatter.cs
- PathFigureCollectionValueSerializer.cs
- KnownBoxes.cs
- WebPartEditorOkVerb.cs
- SqlUtil.cs
- Group.cs
- MembershipPasswordException.cs
- DefaultValueTypeConverter.cs
- StyleBamlRecordReader.cs
- AsymmetricCryptoHandle.cs