Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / ComponentResourceKeyConverter.cs / 1 / ComponentResourceKeyConverter.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
namespace System.Windows.Markup
{
///
/// TypeConverter for a resource value expression
///
public class ComponentResourceKeyConverter : ExpressionConverter
{
///
/// TypeConverter method override.
///
///
/// ITypeDescriptorContext
///
///
/// Type to convert from
///
///
/// true if conversion is possible
///
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == null)
{
throw new ArgumentNullException("sourceType");
}
return base.CanConvertFrom(context, sourceType);
}
///
/// TypeConverter method override.
///
///
/// ITypeDescriptorContext
///
///
/// Type to convert to
///
///
/// true if conversion is possible
///
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
// Validate Input Arguments
if (destinationType == null)
{
throw new ArgumentNullException("destinationType");
}
return base.CanConvertTo(context, destinationType);
}
///
/// TypeConverter method implementation.
///
///
/// ITypeDescriptorContext
///
///
/// current culture (see CLR specs)
///
///
/// value to convert from
///
///
/// value that is result of conversion
///
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
///
/// TypeConverter method implementation.
///
///
/// ITypeDescriptorContext
///
///
/// current culture (see CLR specs)
///
///
/// value to convert from
///
///
/// Type to convert to
///
///
/// converted value
///
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
// Validate Input Arguments
ComponentResourceKey key = value as ComponentResourceKey;
if (key == null)
{
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "ComponentResourceKey"));
}
if (destinationType == null)
{
throw new ArgumentNullException("destinationType");
}
return base.CanConvertTo(context, destinationType);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
namespace System.Windows.Markup
{
///
/// TypeConverter for a resource value expression
///
public class ComponentResourceKeyConverter : ExpressionConverter
{
///
/// TypeConverter method override.
///
///
/// ITypeDescriptorContext
///
///
/// Type to convert from
///
///
/// true if conversion is possible
///
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == null)
{
throw new ArgumentNullException("sourceType");
}
return base.CanConvertFrom(context, sourceType);
}
///
/// TypeConverter method override.
///
///
/// ITypeDescriptorContext
///
///
/// Type to convert to
///
///
/// true if conversion is possible
///
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
// Validate Input Arguments
if (destinationType == null)
{
throw new ArgumentNullException("destinationType");
}
return base.CanConvertTo(context, destinationType);
}
///
/// TypeConverter method implementation.
///
///
/// ITypeDescriptorContext
///
///
/// current culture (see CLR specs)
///
///
/// value to convert from
///
///
/// value that is result of conversion
///
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
///
/// TypeConverter method implementation.
///
///
/// ITypeDescriptorContext
///
///
/// current culture (see CLR specs)
///
///
/// value to convert from
///
///
/// Type to convert to
///
///
/// converted value
///
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
// Validate Input Arguments
ComponentResourceKey key = value as ComponentResourceKey;
if (key == null)
{
throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "ComponentResourceKey"));
}
if (destinationType == null)
{
throw new ArgumentNullException("destinationType");
}
return base.CanConvertTo(context, destinationType);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlAutoDetectWriter.cs
- ScriptIgnoreAttribute.cs
- ElementNotEnabledException.cs
- HtmlGenericControl.cs
- KeyInterop.cs
- HttpCachePolicyElement.cs
- Token.cs
- WorkflowTimerService.cs
- TrackBar.cs
- MemoryPressure.cs
- AvTraceFormat.cs
- SqlMultiplexer.cs
- XamlToRtfWriter.cs
- ContravarianceAdapter.cs
- WindowsStatic.cs
- DivideByZeroException.cs
- ValuePattern.cs
- HtmlElementCollection.cs
- XmlDataSourceView.cs
- DataServiceQueryContinuation.cs
- StylusCaptureWithinProperty.cs
- AuthorizationRuleCollection.cs
- UpWmlMobileTextWriter.cs
- NumberSubstitution.cs
- CodePropertyReferenceExpression.cs
- TextEffect.cs
- TreeNodeStyleCollection.cs
- NetNamedPipeSecurityMode.cs
- FileEnumerator.cs
- StoragePropertyMapping.cs
- TablePatternIdentifiers.cs
- X509CertificateTrustedIssuerElementCollection.cs
- QilFunction.cs
- CompareValidator.cs
- DbConnectionPoolGroup.cs
- StructuralCache.cs
- ParameterModifier.cs
- Rotation3DKeyFrameCollection.cs
- TextEditorDragDrop.cs
- PropertiesTab.cs
- DbBuffer.cs
- EntityWithChangeTrackerStrategy.cs
- GridProviderWrapper.cs
- CharKeyFrameCollection.cs
- TabItemWrapperAutomationPeer.cs
- AutomationPattern.cs
- CompareValidator.cs
- LogEntryHeaderSerializer.cs
- SignatureTargetIdManager.cs
- RegexRunnerFactory.cs
- RuleDefinitions.cs
- ParserStreamGeometryContext.cs
- StrokeRenderer.cs
- Renderer.cs
- ByteStack.cs
- CSharpCodeProvider.cs
- CompositeControlDesigner.cs
- DataServiceExpressionVisitor.cs
- CryptoConfig.cs
- LinkedResourceCollection.cs
- TreeNodeStyleCollection.cs
- RangeBase.cs
- TrackPointCollection.cs
- PropertyKey.cs
- SiteMapDesignerDataSourceView.cs
- ProxyHelper.cs
- PrintSystemException.cs
- CompressEmulationStream.cs
- BitmapEffectOutputConnector.cs
- StreamSecurityUpgradeAcceptorBase.cs
- WebPartActionVerb.cs
- WorkflowApplicationTerminatedException.cs
- StandardCommandToolStripMenuItem.cs
- __Filters.cs
- SignedXml.cs
- SqlUDTStorage.cs
- ExceptionUtil.cs
- WebMessageFormatHelper.cs
- ExpressionQuoter.cs
- EqualityComparer.cs
- DataGridRelationshipRow.cs
- DataGridViewCellFormattingEventArgs.cs
- EditorPartCollection.cs
- LogEntrySerializationException.cs
- SqlDependency.cs
- OdbcDataAdapter.cs
- ContentControl.cs
- Utils.cs
- NavigatorInvalidBodyAccessException.cs
- OdbcError.cs
- XmlSchemaInclude.cs
- ByteKeyFrameCollection.cs
- SQLBoolean.cs
- XmlSchemaSimpleTypeUnion.cs
- XmlTextReaderImplHelpers.cs
- X509ThumbprintKeyIdentifierClause.cs
- PrefixHandle.cs
- SystemThemeKey.cs
- ListBoxItemWrapperAutomationPeer.cs
- DragEvent.cs