Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DesignTimeTemplateParser.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- PageCodeDomTreeGenerator.cs
- TextRangeProviderWrapper.cs
- ManagedIStream.cs
- MsmqHostedTransportConfiguration.cs
- ConvertEvent.cs
- KeyedHashAlgorithm.cs
- UserPersonalizationStateInfo.cs
- MachineKeySection.cs
- FileLevelControlBuilderAttribute.cs
- ToolStripDropDownItem.cs
- HtmlInputFile.cs
- UnmanagedMarshal.cs
- RadialGradientBrush.cs
- HtmlTableRow.cs
- Stacktrace.cs
- SqlTypesSchemaImporter.cs
- RowToParametersTransformer.cs
- Logging.cs
- XPathDocumentNavigator.cs
- ObjectKeyFrameCollection.cs
- LinkClickEvent.cs
- MouseWheelEventArgs.cs
- CodeAccessPermission.cs
- GenericsInstances.cs
- ClipboardData.cs
- BaseCAMarshaler.cs
- DataTablePropertyDescriptor.cs
- XmlEncodedRawTextWriter.cs
- QilUnary.cs
- DataPagerFieldItem.cs
- _UncName.cs
- OrderPreservingSpoolingTask.cs
- ServiceHost.cs
- ListBoxItemWrapperAutomationPeer.cs
- _SslSessionsCache.cs
- X509Certificate.cs
- LineServicesCallbacks.cs
- DataGridViewColumnHeaderCell.cs
- AddInSegmentDirectoryNotFoundException.cs
- DetailsViewCommandEventArgs.cs
- DbConnectionStringCommon.cs
- PrintDialog.cs
- DataStorage.cs
- Module.cs
- TextModifier.cs
- ChannelCacheSettings.cs
- GridViewColumnHeader.cs
- TabPage.cs
- SystemNetworkInterface.cs
- FirstQueryOperator.cs
- IfElseDesigner.xaml.cs
- ReaderContextStackData.cs
- Transform3D.cs
- ObjectItemCachedAssemblyLoader.cs
- UnionCodeGroup.cs
- QuaternionIndependentAnimationStorage.cs
- HttpFileCollection.cs
- EndpointDispatcherTable.cs
- OutputCacheProfileCollection.cs
- AdRotator.cs
- CompilationUtil.cs
- Rethrow.cs
- X509Certificate.cs
- XmlEnumAttribute.cs
- DataSourceControl.cs
- SessionEndedEventArgs.cs
- Transform3DCollection.cs
- SiteMapPath.cs
- DataGridLinkButton.cs
- StrokeNode.cs
- TextProperties.cs
- LinqDataSourceUpdateEventArgs.cs
- BinaryObjectReader.cs
- CodeCommentStatementCollection.cs
- ExceptionUtil.cs
- GatewayDefinition.cs
- dataprotectionpermission.cs
- AxHost.cs
- XmlQualifiedNameTest.cs
- PictureBox.cs
- ArraySortHelper.cs
- CommonProperties.cs
- TypeFieldSchema.cs
- FastPropertyAccessor.cs
- TextCompositionEventArgs.cs
- FlowDocumentReader.cs
- InputManager.cs
- DebuggerAttributes.cs
- RemotingAttributes.cs
- DataGridViewAccessibleObject.cs
- Monitor.cs
- coordinatorfactory.cs
- CapabilitiesPattern.cs
- COM2Enum.cs
- TdsParserHelperClasses.cs
- GCHandleCookieTable.cs
- CursorConverter.cs
- CharacterString.cs