Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- SecurityUtils.cs
- EditingMode.cs
- nulltextcontainer.cs
- ClientTargetSection.cs
- XmlTypeAttribute.cs
- StyleBamlTreeBuilder.cs
- Rule.cs
- InternalControlCollection.cs
- TableStyle.cs
- DependencySource.cs
- Transform3D.cs
- XmlQuerySequence.cs
- SelectionUIService.cs
- _SecureChannel.cs
- ClientCultureInfo.cs
- DataServiceQueryException.cs
- QilStrConcatenator.cs
- DrawingAttributesDefaultValueFactory.cs
- Root.cs
- GlyphRunDrawing.cs
- AsyncOperation.cs
- PointF.cs
- ResourceSetExpression.cs
- ThreadExceptionEvent.cs
- NameValuePermission.cs
- TemplateControl.cs
- CallbackValidatorAttribute.cs
- UnionCodeGroup.cs
- CodeCastExpression.cs
- ICspAsymmetricAlgorithm.cs
- ZoomPercentageConverter.cs
- DebugHandleTracker.cs
- DesignerForm.cs
- ExpressionVisitorHelpers.cs
- BitmapInitialize.cs
- ChineseLunisolarCalendar.cs
- UnsafeNativeMethodsCLR.cs
- TrackingMemoryStream.cs
- DocumentsTrace.cs
- CompositeControl.cs
- MSAANativeProvider.cs
- CryptoStream.cs
- ScaleTransform3D.cs
- MemoryRecordBuffer.cs
- CodeGen.cs
- Point3DCollection.cs
- MasterPage.cs
- MenuAutomationPeer.cs
- WorkflowPersistenceContext.cs
- UnionCodeGroup.cs
- PerformanceCountersElement.cs
- MimePart.cs
- DataViewManager.cs
- SqlMetaData.cs
- SystemIPv6InterfaceProperties.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- _LoggingObject.cs
- Nodes.cs
- LongValidatorAttribute.cs
- FlowLayoutSettings.cs
- UmAlQuraCalendar.cs
- WindowsContainer.cs
- ResourcePool.cs
- Guid.cs
- ComponentEditorPage.cs
- Exceptions.cs
- TextureBrush.cs
- CheckBoxList.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- DataTableNewRowEvent.cs
- MessageHeaders.cs
- ProxyAttribute.cs
- HttpSocketManager.cs
- RootProfilePropertySettingsCollection.cs
- WebBrowserProgressChangedEventHandler.cs
- UnsupportedPolicyOptionsException.cs
- FormViewDeleteEventArgs.cs
- ListViewItemSelectionChangedEvent.cs
- VerificationException.cs
- HttpDebugHandler.cs
- _SslState.cs
- CollaborationHelperFunctions.cs
- XmlAttributeAttribute.cs
- ColumnResizeUndoUnit.cs
- DbXmlEnabledProviderManifest.cs
- RelationshipConverter.cs
- WebEventCodes.cs
- CharacterHit.cs
- ServiceHttpModule.cs
- DependencyProperty.cs
- SafeRightsManagementHandle.cs
- ArraySubsetEnumerator.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- MenuAdapter.cs
- Token.cs
- WorkItem.cs
- PeerObject.cs
- DragEvent.cs
- NetworkInformationPermission.cs
- IISUnsafeMethods.cs