Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / DynamicResourceExtensionConverter.cs / 1 / DynamicResourceExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // DynamicResourceExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Security; using System.Text; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a DynamicResourceExtension from /// an instance. It reports that ResourceKey should be used as the first parameter to the constructor. /// public class DynamicResourceExtensionConverter: TypeConverter { ////// True if converting to an instance descriptor /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Converts to an instance descriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for DynamicResourceExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; if (dynamicResource == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "DynamicResourceExtension"), "value"); return new InstanceDescriptor(typeof(DynamicResourceExtension).GetConstructor(new Type[] { typeof(object) }), new object[] { dynamicResource.ResourceKey } ); } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // DynamicResourceExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Security; using System.Text; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a DynamicResourceExtension from /// an instance. It reports that ResourceKey should be used as the first parameter to the constructor. /// public class DynamicResourceExtensionConverter: TypeConverter { ////// True if converting to an instance descriptor /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Converts to an instance descriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for DynamicResourceExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; if (dynamicResource == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "DynamicResourceExtension"), "value"); return new InstanceDescriptor(typeof(DynamicResourceExtension).GetConstructor(new Type[] { typeof(object) }), new object[] { dynamicResource.ResourceKey } ); } return base.ConvertTo(context, culture, value, 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
- XmlSerializationWriter.cs
- BamlRecordHelper.cs
- FileSystemEventArgs.cs
- SqlMethodTransformer.cs
- AppDomainShutdownMonitor.cs
- MyContact.cs
- DisplayInformation.cs
- ReadOnlyCollection.cs
- ComplexBindingPropertiesAttribute.cs
- TextModifierScope.cs
- WebMessageEncoderFactory.cs
- VScrollProperties.cs
- ServicePointManagerElement.cs
- UnhandledExceptionEventArgs.cs
- GeometryGroup.cs
- DefaultMemberAttribute.cs
- QilList.cs
- LicenseManager.cs
- CommandConverter.cs
- WizardPanel.cs
- ConfigurationSettings.cs
- XsdCachingReader.cs
- Typography.cs
- ToolStripItemBehavior.cs
- StylusDownEventArgs.cs
- ChannelManager.cs
- FixedSOMTableCell.cs
- TypeSemantics.cs
- BevelBitmapEffect.cs
- RangeValuePattern.cs
- CategoryAttribute.cs
- Stack.cs
- DbProviderFactoriesConfigurationHandler.cs
- SelectionPatternIdentifiers.cs
- NodeInfo.cs
- XpsFilter.cs
- FormsAuthenticationUser.cs
- WebScriptEnablingBehavior.cs
- SQLInt16.cs
- ClrProviderManifest.cs
- AccessedThroughPropertyAttribute.cs
- TextEditorCopyPaste.cs
- StructuredProperty.cs
- Int32Rect.cs
- Schema.cs
- CapacityStreamGeometryContext.cs
- UnwrappedTypesXmlSerializerManager.cs
- Operator.cs
- HealthMonitoringSection.cs
- BorderSidesEditor.cs
- CachedBitmap.cs
- _Semaphore.cs
- HtmlTableRowCollection.cs
- Win32.cs
- FontNameEditor.cs
- RuntimeConfigLKG.cs
- ListSortDescription.cs
- FileIOPermission.cs
- GlobalizationSection.cs
- SafeProcessHandle.cs
- Font.cs
- SystemIcmpV6Statistics.cs
- CodeNamespace.cs
- HMACSHA384.cs
- XmlAttribute.cs
- HttpCookieCollection.cs
- BlurBitmapEffect.cs
- BamlRecordHelper.cs
- ApplicationHost.cs
- VisualBrush.cs
- SeekStoryboard.cs
- StringFunctions.cs
- RegexGroup.cs
- TypeSystem.cs
- ListViewItemSelectionChangedEvent.cs
- CompiledQueryCacheEntry.cs
- ConfigXmlElement.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- IPAddressCollection.cs
- WebPartMinimizeVerb.cs
- DataGridViewSelectedRowCollection.cs
- BinaryReader.cs
- SqlBulkCopy.cs
- _TimerThread.cs
- OperationResponse.cs
- ZipIOFileItemStream.cs
- Converter.cs
- RootBuilder.cs
- SqlDependencyListener.cs
- ThicknessKeyFrameCollection.cs
- ConversionHelper.cs
- UshortList2.cs
- ReliableChannelFactory.cs
- StringConverter.cs
- CaseStatementSlot.cs
- PartManifestEntry.cs
- MSG.cs
- NullableFloatMinMaxAggregationOperator.cs
- ResizeGrip.cs
- BindingParameterCollection.cs