Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DynamicResourceExtensionConverter.cs / 1305600 / 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
- PartialTrustVisibleAssembly.cs
- WindowsFormsSynchronizationContext.cs
- SqlXmlStorage.cs
- RouteItem.cs
- ChangeConflicts.cs
- TokenCreationException.cs
- WebException.cs
- counter.cs
- DataGridItemAutomationPeer.cs
- AvtEvent.cs
- TagMapCollection.cs
- MetadataItemEmitter.cs
- OdbcParameterCollection.cs
- BigInt.cs
- MsdtcWrapper.cs
- storagemappingitemcollection.viewdictionary.cs
- XmlFileEditor.cs
- BaseCAMarshaler.cs
- EntityClassGenerator.cs
- TextSchema.cs
- CharEnumerator.cs
- ResourcePermissionBaseEntry.cs
- ReflectTypeDescriptionProvider.cs
- Asn1IntegerConverter.cs
- DPAPIProtectedConfigurationProvider.cs
- RestHandler.cs
- WindowsEditBox.cs
- ImmComposition.cs
- ImageListUtils.cs
- CachedResourceDictionaryExtension.cs
- ProfileEventArgs.cs
- Line.cs
- RightsManagementLicense.cs
- ValidateNames.cs
- ListView.cs
- TransformerConfigurationWizardBase.cs
- ADMembershipUser.cs
- CustomAssemblyResolver.cs
- QueryRewriter.cs
- ImpersonateTokenRef.cs
- SessionEndingCancelEventArgs.cs
- StringAnimationBase.cs
- StaticTextPointer.cs
- TemplateParser.cs
- NativeMethodsOther.cs
- ConstructorNeedsTagAttribute.cs
- ToolZone.cs
- LocatorManager.cs
- TagNameToTypeMapper.cs
- PageFunction.cs
- AssemblyNameProxy.cs
- ApplicationServiceHelper.cs
- SqlRecordBuffer.cs
- RtfToXamlLexer.cs
- LogPolicy.cs
- FixedSOMTextRun.cs
- CodeTypeDeclarationCollection.cs
- ProviderCollection.cs
- PointKeyFrameCollection.cs
- FixedTextView.cs
- WebPartTransformer.cs
- ToolStripDropDownClosedEventArgs.cs
- DataGridHyperlinkColumn.cs
- DataKeyPropertyAttribute.cs
- InvokeHandlers.cs
- DataGridGeneralPage.cs
- ButtonChrome.cs
- PointAnimationUsingKeyFrames.cs
- PowerModeChangedEventArgs.cs
- WebPartVerb.cs
- OperatingSystemVersionCheck.cs
- DataPager.cs
- DbDeleteCommandTree.cs
- ManagedFilter.cs
- FileDialogPermission.cs
- NameSpaceExtractor.cs
- EntityWrapperFactory.cs
- SafeBitVector32.cs
- RelatedPropertyManager.cs
- XmlBoundElement.cs
- PropertyBuilder.cs
- Stylus.cs
- SamlAttributeStatement.cs
- HttpInputStream.cs
- EntityStoreSchemaGenerator.cs
- BaseParagraph.cs
- RijndaelManagedTransform.cs
- ErrorsHelper.cs
- DateTimeConstantAttribute.cs
- TemplatedWizardStep.cs
- InvalidProgramException.cs
- CallbackHandler.cs
- Triplet.cs
- PerformanceCounterManager.cs
- LicenseContext.cs
- EntityKey.cs
- StatusBarDrawItemEvent.cs
- Codec.cs
- SafeRightsManagementPubHandle.cs
- AccessDataSourceWizardForm.cs