Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / ComponentResourceKeyConverter.cs / 1305600 / 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
- InputLanguageEventArgs.cs
- EncoderFallback.cs
- ObjectConverter.cs
- GridItem.cs
- ColorAnimationUsingKeyFrames.cs
- SocketElement.cs
- PaperSize.cs
- ControlPropertyNameConverter.cs
- ListControlConvertEventArgs.cs
- SecurityTokenRequirement.cs
- ObservableCollection.cs
- Rules.cs
- ServiceModelSecurityTokenTypes.cs
- EventProviderWriter.cs
- XamlSerializerUtil.cs
- CodeVariableReferenceExpression.cs
- UIElement3DAutomationPeer.cs
- TrailingSpaceComparer.cs
- SystemPens.cs
- FilePresentation.cs
- ProcessModelSection.cs
- SpecularMaterial.cs
- webeventbuffer.cs
- RtfToXamlReader.cs
- InfoCardCryptoHelper.cs
- HandlerBase.cs
- OutputChannelBinder.cs
- HtmlImage.cs
- AddInController.cs
- HttpListenerRequestUriBuilder.cs
- DbConnectionStringBuilder.cs
- CreateUserWizard.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- rsa.cs
- StringComparer.cs
- SqlDataSourceStatusEventArgs.cs
- PointAnimationBase.cs
- RowToParametersTransformer.cs
- ADMembershipUser.cs
- TreeViewEvent.cs
- SendingRequestEventArgs.cs
- SqlUtils.cs
- Range.cs
- AnnotationResourceChangedEventArgs.cs
- CorrelationHandle.cs
- AccessDataSourceView.cs
- ScrollPattern.cs
- HtmlInputControl.cs
- SizeAnimationClockResource.cs
- ModelVisual3D.cs
- DockPanel.cs
- BitmapImage.cs
- WebBrowserProgressChangedEventHandler.cs
- DesignerAdapterUtil.cs
- ProcessingInstructionAction.cs
- ILGenerator.cs
- ResolveNameEventArgs.cs
- Expressions.cs
- TextComposition.cs
- TableSectionStyle.cs
- InvalidPrinterException.cs
- ListViewGroupItemCollection.cs
- FixedSOMContainer.cs
- ScriptModule.cs
- LookupNode.cs
- TextDecorationCollection.cs
- GlobalDataBindingHandler.cs
- SQLDateTime.cs
- MailDefinition.cs
- FixedHyperLink.cs
- KnownIds.cs
- ChannelTracker.cs
- BoundsDrawingContextWalker.cs
- EntitySetBase.cs
- FatalException.cs
- ConfigXmlSignificantWhitespace.cs
- CodeLinePragma.cs
- ExpressionVisitor.cs
- SubstitutionList.cs
- BitmapEffect.cs
- OneOfTypeConst.cs
- CodeDefaultValueExpression.cs
- CommandHelpers.cs
- RTLAwareMessageBox.cs
- documentsequencetextview.cs
- _RequestCacheProtocol.cs
- QueueProcessor.cs
- Membership.cs
- PartitionResolver.cs
- TableColumnCollection.cs
- DateTimeFormat.cs
- MimeMapping.cs
- PauseStoryboard.cs
- MetadataPropertyAttribute.cs
- WorkflowViewService.cs
- DirectoryObjectSecurity.cs
- AsymmetricSignatureFormatter.cs
- DbMetaDataFactory.cs
- ComponentDesigner.cs
- WebBrowser.cs