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
- SerialErrors.cs
- EventlogProvider.cs
- Int32EqualityComparer.cs
- DecimalFormatter.cs
- OperandQuery.cs
- ServiceAuthorizationBehavior.cs
- Zone.cs
- UmAlQuraCalendar.cs
- SurrogateDataContract.cs
- MimePart.cs
- AudioBase.cs
- ComContractElement.cs
- ContentTextAutomationPeer.cs
- KnownTypeAttribute.cs
- DataBoundControlHelper.cs
- DragEventArgs.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SecureStringHasher.cs
- AlphaSortedEnumConverter.cs
- ToolboxItemCollection.cs
- SiteMembershipCondition.cs
- RtfFormatStack.cs
- FlowDocumentPage.cs
- TableCellCollection.cs
- Process.cs
- PopupRoot.cs
- TableStyle.cs
- Stack.cs
- DataKey.cs
- HandlerBase.cs
- TemplateLookupAction.cs
- LingerOption.cs
- DES.cs
- Window.cs
- DeferredReference.cs
- ClientRuntime.cs
- MsmqEncryptionAlgorithm.cs
- CodeDirectoryCompiler.cs
- UriSection.cs
- EditorOptionAttribute.cs
- EntityDataSourceChangedEventArgs.cs
- RenderingBiasValidation.cs
- ObjectDataSourceDisposingEventArgs.cs
- ArrangedElement.cs
- KeyEvent.cs
- PriorityBindingExpression.cs
- FontDialog.cs
- RankException.cs
- XpsFilter.cs
- StoryFragments.cs
- Attachment.cs
- LineServices.cs
- TextServicesPropertyRanges.cs
- XPathArrayIterator.cs
- InvalidPrinterException.cs
- FacetChecker.cs
- WorkflowRuntimeSection.cs
- DeviceContexts.cs
- ParagraphVisual.cs
- SqlDataSourceCustomCommandEditor.cs
- Graphics.cs
- RangeBase.cs
- ThreadSafeMessageFilterTable.cs
- ProcessThreadDesigner.cs
- PrintDialog.cs
- SourceExpressionException.cs
- DynamicObject.cs
- SafeNativeMethods.cs
- PreviewPageInfo.cs
- XmlDocument.cs
- LinqDataSourceDeleteEventArgs.cs
- Transactions.cs
- XPathNodeInfoAtom.cs
- WebPartConnectionsDisconnectVerb.cs
- DataServiceQuery.cs
- ListItem.cs
- BlurEffect.cs
- GroupStyle.cs
- TypeToken.cs
- NameValueCollection.cs
- StringWriter.cs
- ConsoleKeyInfo.cs
- Function.cs
- HttpResponseHeader.cs
- HtmlInputImage.cs
- _Rfc2616CacheValidators.cs
- DataSourceView.cs
- HtmlInputPassword.cs
- XPathSingletonIterator.cs
- httpapplicationstate.cs
- UserControlDocumentDesigner.cs
- BulletDecorator.cs
- EpmContentDeSerializerBase.cs
- RelationalExpressions.cs
- HtmlTableCell.cs
- GPStream.cs
- StringAnimationUsingKeyFrames.cs
- MulticastNotSupportedException.cs
- PersonalizationEntry.cs
- Error.cs