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 / 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
- AppModelKnownContentFactory.cs
- ArgumentDirectionHelper.cs
- NumberAction.cs
- GraphicsContext.cs
- NameTable.cs
- ContextQuery.cs
- EntityRecordInfo.cs
- _Connection.cs
- MembershipPasswordException.cs
- CallbackValidator.cs
- Helpers.cs
- HasCopySemanticsAttribute.cs
- OleAutBinder.cs
- AutomationProperties.cs
- QuaternionKeyFrameCollection.cs
- OdbcInfoMessageEvent.cs
- VectorValueSerializer.cs
- CqlParser.cs
- PrivilegeNotHeldException.cs
- WindowCollection.cs
- NavigationWindowAutomationPeer.cs
- XmlSerializerFactory.cs
- SerialPort.cs
- ToolStripItemImageRenderEventArgs.cs
- AuthenticateEventArgs.cs
- FixUpCollection.cs
- Object.cs
- VariantWrapper.cs
- DataGrid.cs
- WebPartAddingEventArgs.cs
- WebPartDescriptionCollection.cs
- PackagePart.cs
- EnumValidator.cs
- XmlSchemaAttributeGroup.cs
- WebPartCatalogAddVerb.cs
- SecurityIdentifierElement.cs
- NumberFunctions.cs
- Vector.cs
- CustomAttribute.cs
- Expression.DebuggerProxy.cs
- XmlStringTable.cs
- CheckBoxRenderer.cs
- VisualState.cs
- ISAPIApplicationHost.cs
- RightNameExpirationInfoPair.cs
- SurrogateEncoder.cs
- DropTarget.cs
- MetadataWorkspace.cs
- IgnoreSection.cs
- AccessViolationException.cs
- DirectoryGroupQuery.cs
- SuppressMergeCheckAttribute.cs
- IsolatedStorageFilePermission.cs
- HwndProxyElementProvider.cs
- BlurEffect.cs
- SqlServer2KCompatibilityCheck.cs
- OdbcParameterCollection.cs
- validationstate.cs
- DocumentOrderQuery.cs
- COM2PictureConverter.cs
- PhoneCallDesigner.cs
- ErrorLog.cs
- LogicalTreeHelper.cs
- WpfPayload.cs
- SqlRecordBuffer.cs
- DesignerDeviceConfig.cs
- ActivityAction.cs
- DataGridViewCellStateChangedEventArgs.cs
- DesignTimeVisibleAttribute.cs
- UserInitiatedRoutedEventPermission.cs
- UniqueIdentifierService.cs
- SimpleBitVector32.cs
- ReadOnlyHierarchicalDataSource.cs
- EventManager.cs
- MediaContextNotificationWindow.cs
- IsolatedStorageFile.cs
- COM2PropertyDescriptor.cs
- DefaultDialogButtons.cs
- CharEnumerator.cs
- OAVariantLib.cs
- ModuleBuilder.cs
- EditorPartChrome.cs
- ChildrenQuery.cs
- GlobalItem.cs
- RbTree.cs
- Configuration.cs
- GacUtil.cs
- CursorInteropHelper.cs
- Crc32Helper.cs
- SerialErrors.cs
- figurelength.cs
- KerberosSecurityTokenAuthenticator.cs
- InvalidOleVariantTypeException.cs
- WebConfigurationHost.cs
- MaskDesignerDialog.cs
- ReliableChannelBinder.cs
- EntityClientCacheKey.cs
- SecurityKeyIdentifierClause.cs
- Memoizer.cs
- SchemaCollectionCompiler.cs