Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ReceiveContext.cs
- WindowsGraphicsWrapper.cs
- CommonBehaviorsSection.cs
- ConfigXmlCDataSection.cs
- ExtensionWindowHeader.cs
- SessionStateSection.cs
- TreeView.cs
- ToolStrip.cs
- XmlAutoDetectWriter.cs
- LicenseException.cs
- AsymmetricSignatureFormatter.cs
- DependencyPropertyConverter.cs
- SignedInfo.cs
- CacheOutputQuery.cs
- TextTreeNode.cs
- RowUpdatedEventArgs.cs
- Properties.cs
- SmtpCommands.cs
- CellLabel.cs
- QueryCoreOp.cs
- EffectiveValueEntry.cs
- ExternalException.cs
- InternalBufferManager.cs
- IPAddressCollection.cs
- SoapEnumAttribute.cs
- StylusCollection.cs
- UserValidatedEventArgs.cs
- PageAdapter.cs
- SqlAggregateChecker.cs
- Camera.cs
- CommonGetThemePartSize.cs
- util.cs
- Subordinate.cs
- MachineKeyValidationConverter.cs
- Point3DKeyFrameCollection.cs
- CodeAccessSecurityEngine.cs
- shaperfactory.cs
- CodeArrayIndexerExpression.cs
- InheritedPropertyDescriptor.cs
- ModelUIElement3D.cs
- Encoder.cs
- CodeExporter.cs
- Decoder.cs
- XmlDataSourceView.cs
- _NestedSingleAsyncResult.cs
- XmlImplementation.cs
- OperatingSystem.cs
- Enum.cs
- HttpInputStream.cs
- CorePropertiesFilter.cs
- AccessText.cs
- MenuAutomationPeer.cs
- PrintingPermissionAttribute.cs
- FileSystemEventArgs.cs
- PathData.cs
- ImageDrawing.cs
- SafeHandles.cs
- SuppressMessageAttribute.cs
- TagPrefixInfo.cs
- DescendantOverDescendantQuery.cs
- WebReferencesBuildProvider.cs
- ColorInterpolationModeValidation.cs
- BehaviorEditorPart.cs
- SqlDataReaderSmi.cs
- StreamWithDictionary.cs
- DesignerGeometryHelper.cs
- ExtenderControl.cs
- TabItem.cs
- ObjectContext.cs
- ApplicationFileCodeDomTreeGenerator.cs
- DataControlFieldHeaderCell.cs
- errorpatternmatcher.cs
- FlowDocumentFormatter.cs
- RandomDelayQueuedSendsAsyncResult.cs
- SQLMoney.cs
- TraceRecord.cs
- ColorComboBox.cs
- CodeBinaryOperatorExpression.cs
- WebPartConnectionsConnectVerb.cs
- UriTemplateTrieLocation.cs
- StructuredTypeEmitter.cs
- ToolStripPanelRow.cs
- UnknownBitmapDecoder.cs
- CallbackException.cs
- AppDomain.cs
- MinimizableAttributeTypeConverter.cs
- RuntimeWrappedException.cs
- XmlSerializerFactory.cs
- DefaultExpression.cs
- ColorTransformHelper.cs
- DocumentOrderQuery.cs
- AttachedPropertiesService.cs
- ConnectionString.cs
- Rect.cs
- BufferBuilder.cs
- WindowsHyperlink.cs
- HttpDateParse.cs
- CookielessData.cs
- base64Transforms.cs
- WebControl.cs