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
- XmlReader.cs
- PathFigure.cs
- RemoteWebConfigurationHostStream.cs
- KeySpline.cs
- ExplicitDiscriminatorMap.cs
- FlowPosition.cs
- XmlSiteMapProvider.cs
- StandardCommands.cs
- DesignerExtenders.cs
- XmlAttribute.cs
- PauseStoryboard.cs
- MenuItemCollection.cs
- BehaviorEditorPart.cs
- ProxyWebPart.cs
- DataGrid.cs
- TextClipboardData.cs
- AtomParser.cs
- Number.cs
- MemberHolder.cs
- ToolStripDropDown.cs
- UxThemeWrapper.cs
- XmlException.cs
- ComProxy.cs
- InputManager.cs
- Point3DIndependentAnimationStorage.cs
- DataFormats.cs
- AttributeTableBuilder.cs
- DataError.cs
- PostBackOptions.cs
- EditorPartCollection.cs
- RequestCachingSection.cs
- XmlWellformedWriterHelpers.cs
- Primitive.cs
- SqlTransaction.cs
- Module.cs
- SystemInformation.cs
- Queue.cs
- DocumentApplication.cs
- OuterGlowBitmapEffect.cs
- ProfileBuildProvider.cs
- ExtendedPropertyInfo.cs
- Rfc2898DeriveBytes.cs
- QueryRewriter.cs
- RegexCharClass.cs
- DeclaredTypeValidator.cs
- DataGridColumnCollection.cs
- FileFormatException.cs
- AsyncPostBackErrorEventArgs.cs
- recordstate.cs
- MediaSystem.cs
- FormatConvertedBitmap.cs
- StructuralCache.cs
- BaseTreeIterator.cs
- HtmlTable.cs
- MatrixTransform.cs
- SiteMapNodeItemEventArgs.cs
- CompoundFileDeflateTransform.cs
- CountdownEvent.cs
- Ops.cs
- WinEventQueueItem.cs
- updateconfighost.cs
- ValidatedControlConverter.cs
- SendActivity.cs
- AsynchronousChannelMergeEnumerator.cs
- XmlAttributeCollection.cs
- LeaseManager.cs
- BuildResultCache.cs
- TypeTypeConverter.cs
- StringValidator.cs
- DebugView.cs
- PingOptions.cs
- TraceHwndHost.cs
- ObjectIDGenerator.cs
- IisTraceWebEventProvider.cs
- nulltextcontainer.cs
- JsonSerializer.cs
- BitmapEffectDrawing.cs
- Soap12ProtocolImporter.cs
- TextTreePropertyUndoUnit.cs
- RootProjectionNode.cs
- DebugInfoExpression.cs
- DiagnosticsConfiguration.cs
- StrongBox.cs
- OleDbRowUpdatedEvent.cs
- SweepDirectionValidation.cs
- RadioButtonList.cs
- RelatedPropertyManager.cs
- BamlLocalizableResourceKey.cs
- StaticExtensionConverter.cs
- RSAPKCS1KeyExchangeFormatter.cs
- CrossContextChannel.cs
- ObjectSet.cs
- NativeConfigurationLoader.cs
- DocumentPaginator.cs
- AncillaryOps.cs
- PeerObject.cs
- SaveFileDialog.cs
- UnionCodeGroup.cs
- EntityTypeEmitter.cs
- XmlIterators.cs