Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Serialization / FormatterConverter.cs / 1305376 / 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; using System.Diagnostics.Contracts; [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"); } Contract.EndContractBlock(); return System.Convert.ChangeType(value, type, CultureInfo.InvariantCulture); } public Object Convert(Object value, TypeCode typeCode) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture); } public bool ToBoolean(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToBoolean(value, CultureInfo.InvariantCulture); } public char ToChar(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToChar(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public sbyte ToSByte(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToSByte(value, CultureInfo.InvariantCulture); } public byte ToByte(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToByte(value, CultureInfo.InvariantCulture); } public short ToInt16(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToInt16(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public ushort ToUInt16(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToUInt16(value, CultureInfo.InvariantCulture); } public int ToInt32(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToInt32(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public uint ToUInt32(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToUInt32(value, CultureInfo.InvariantCulture); } public long ToInt64(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToInt64(value, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public ulong ToUInt64(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToUInt64(value, CultureInfo.InvariantCulture); } public float ToSingle(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToSingle(value, CultureInfo.InvariantCulture); } public double ToDouble(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToDouble(value, CultureInfo.InvariantCulture); } public Decimal ToDecimal(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToDecimal(value, CultureInfo.InvariantCulture); } public DateTime ToDateTime(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); return System.Convert.ToDateTime(value, CultureInfo.InvariantCulture); } public String ToString(Object value) { if (value==null) { throw new ArgumentNullException("value"); } Contract.EndContractBlock(); 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
- ExpandableObjectConverter.cs
- OptimisticConcurrencyException.cs
- QilGeneratorEnv.cs
- __Filters.cs
- BroadcastEventHelper.cs
- MergeFilterQuery.cs
- TextMetrics.cs
- ToggleButtonAutomationPeer.cs
- AtlasWeb.Designer.cs
- WmlLinkAdapter.cs
- UpdateProgress.cs
- ProfileGroupSettingsCollection.cs
- EntityWrapperFactory.cs
- SqlProcedureAttribute.cs
- GenericParameterDataContract.cs
- PropertyEntry.cs
- ReadOnlyHierarchicalDataSource.cs
- StoragePropertyMapping.cs
- DropShadowEffect.cs
- BaseConfigurationRecord.cs
- XmlBinaryReader.cs
- Internal.cs
- CollectionChangeEventArgs.cs
- CryptoKeySecurity.cs
- LongValidatorAttribute.cs
- HandlerElement.cs
- ClientCultureInfo.cs
- PackageStore.cs
- ClientCredentialsElement.cs
- PersonalizationStateInfoCollection.cs
- XmlAtomicValue.cs
- GZipDecoder.cs
- DataControlFieldHeaderCell.cs
- AppModelKnownContentFactory.cs
- CodeIterationStatement.cs
- XmlSchema.cs
- MasterPageParser.cs
- IndexedWhereQueryOperator.cs
- ResourceWriter.cs
- LockCookie.cs
- X509SecurityTokenAuthenticator.cs
- UpdateRecord.cs
- HotSpotCollection.cs
- FaultDescription.cs
- QueryModel.cs
- ControlPropertyNameConverter.cs
- DataViewManagerListItemTypeDescriptor.cs
- SettingsSection.cs
- ConvertEvent.cs
- RuntimeIdentifierPropertyAttribute.cs
- SerializationAttributes.cs
- StrongNameMembershipCondition.cs
- FontConverter.cs
- LinkTarget.cs
- InternalBufferOverflowException.cs
- XmlConvert.cs
- FormClosingEvent.cs
- WriteFileContext.cs
- DNS.cs
- BooleanSwitch.cs
- SystemUdpStatistics.cs
- MetadataArtifactLoaderComposite.cs
- MouseGesture.cs
- ToolboxItemCollection.cs
- OrCondition.cs
- LocalizationParserHooks.cs
- basecomparevalidator.cs
- DataGridViewCellLinkedList.cs
- NamedObject.cs
- NamedPipeActivation.cs
- Faults.cs
- DocumentViewerHelper.cs
- DbConnectionClosed.cs
- ObjectListSelectEventArgs.cs
- XmlSchemaAnnotation.cs
- CuspData.cs
- Crypto.cs
- ThemeDictionaryExtension.cs
- XNameConverter.cs
- EntityDataSourceWizardForm.cs
- BasicViewGenerator.cs
- Registry.cs
- LocalValueEnumerator.cs
- XmlAttributeProperties.cs
- OperatingSystem.cs
- ContextMenuAutomationPeer.cs
- PreProcessor.cs
- COAUTHINFO.cs
- TextRangeEditTables.cs
- SR.Designer.cs
- ComponentResourceKey.cs
- DefaultValueAttribute.cs
- FrameworkPropertyMetadata.cs
- PngBitmapEncoder.cs
- DataServiceHost.cs
- WebPartZone.cs
- TraceListeners.cs
- SizeConverter.cs
- KeyInterop.cs
- InheritablePropertyChangeInfo.cs