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
- HScrollBar.cs
- ResourceReader.cs
- LayoutTable.cs
- MexHttpBindingCollectionElement.cs
- MonikerBuilder.cs
- AttributeEmitter.cs
- FeatureAttribute.cs
- InputLangChangeRequestEvent.cs
- ObjectStateEntryDbDataRecord.cs
- FormClosingEvent.cs
- KeyGesture.cs
- LambdaCompiler.Lambda.cs
- SlipBehavior.cs
- AttachedPropertyBrowsableAttribute.cs
- BehaviorEditorPart.cs
- ContextMarshalException.cs
- CrossContextChannel.cs
- URI.cs
- Stopwatch.cs
- UnwrappedTypesXmlSerializerManager.cs
- ChangeConflicts.cs
- ByteRangeDownloader.cs
- MatrixValueSerializer.cs
- CodeEntryPointMethod.cs
- XmlSerializerFactory.cs
- RightsManagementEncryptionTransform.cs
- XmlReflectionImporter.cs
- SoapEnumAttribute.cs
- QueryActivatableWorkflowsCommand.cs
- VBCodeProvider.cs
- ShaperBuffers.cs
- BamlMapTable.cs
- ResourceContainer.cs
- ClientBuildManagerCallback.cs
- DisplayMemberTemplateSelector.cs
- XmlSchemaChoice.cs
- ContentType.cs
- CancelEventArgs.cs
- XmlAttributes.cs
- MultiBindingExpression.cs
- Material.cs
- SqlReferenceCollection.cs
- storagemappingitemcollection.viewdictionary.cs
- RoleGroupCollection.cs
- ObjectDataSourceView.cs
- AffineTransform3D.cs
- PropertyReferenceSerializer.cs
- SecurityStateEncoder.cs
- ExpressionParser.cs
- InternalPermissions.cs
- StylusPlugin.cs
- PartitionedStreamMerger.cs
- BitmapSizeOptions.cs
- ClientReliableChannelBinder.cs
- EntityContainer.cs
- XPathDocumentBuilder.cs
- CodeCommentStatementCollection.cs
- ClientApiGenerator.cs
- InputBinder.cs
- DataGridCellsPresenter.cs
- TableAdapterManagerHelper.cs
- BaseProcessProtocolHandler.cs
- ButtonBaseAdapter.cs
- MethodRental.cs
- RowUpdatedEventArgs.cs
- AutomationElement.cs
- ElapsedEventArgs.cs
- MediaContextNotificationWindow.cs
- DelegateTypeInfo.cs
- WebServiceEnumData.cs
- HandlerFactoryCache.cs
- ObjectListComponentEditor.cs
- safelink.cs
- CfgArc.cs
- HtmlShimManager.cs
- bindurihelper.cs
- RegisteredScript.cs
- IImplicitResourceProvider.cs
- WindowClosedEventArgs.cs
- DataGridViewImageColumn.cs
- NativeMethods.cs
- RuntimeConfigLKG.cs
- TransactionsSectionGroup.cs
- VirtualPathUtility.cs
- BitmapCodecInfoInternal.cs
- OdbcConnectionFactory.cs
- LinearGradientBrush.cs
- InputProcessorProfiles.cs
- GradientStop.cs
- TransformerInfo.cs
- _Events.cs
- JavaScriptString.cs
- ScriptHandlerFactory.cs
- SoapObjectReader.cs
- PieceDirectory.cs
- CodeFieldReferenceExpression.cs
- MimeReturn.cs
- TdsRecordBufferSetter.cs
- SrgsElementFactory.cs
- ThicknessConverter.cs