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
- StringFunctions.cs
- ClientSettingsSection.cs
- AllMembershipCondition.cs
- AttachedAnnotation.cs
- ExpressionBuilder.cs
- SmiRecordBuffer.cs
- SQLString.cs
- RootBuilder.cs
- TextEditorMouse.cs
- WebControlAdapter.cs
- PerfService.cs
- DrawListViewSubItemEventArgs.cs
- OleDbInfoMessageEvent.cs
- TextBoxDesigner.cs
- StringKeyFrameCollection.cs
- ImportCatalogPart.cs
- PropertyInfoSet.cs
- Recipient.cs
- TreeNodeCollection.cs
- DoubleAnimationUsingPath.cs
- ConfigXmlWhitespace.cs
- ExtensionWindowResizeGrip.cs
- SvcMapFileSerializer.cs
- CacheModeValueSerializer.cs
- BitmapMetadata.cs
- VisualStyleElement.cs
- HMACSHA512.cs
- HttpStaticObjectsCollectionWrapper.cs
- DES.cs
- SqlInternalConnectionTds.cs
- WebInvokeAttribute.cs
- TreeViewImageIndexConverter.cs
- BitmapEffectInputData.cs
- Block.cs
- XmlHierarchicalEnumerable.cs
- DynamicFilter.cs
- GlobalAllocSafeHandle.cs
- Matrix3D.cs
- SymDocumentType.cs
- DES.cs
- AxisAngleRotation3D.cs
- ContentElementAutomationPeer.cs
- GridViewAutoFormat.cs
- ProxyWebPartConnectionCollection.cs
- UITypeEditor.cs
- SectionXmlInfo.cs
- HelpInfo.cs
- _BufferOffsetSize.cs
- SharedStatics.cs
- XmlRawWriter.cs
- CultureTableRecord.cs
- ObjectSecurityT.cs
- PreservationFileReader.cs
- ScriptingSectionGroup.cs
- MonitoringDescriptionAttribute.cs
- Utils.cs
- PositiveTimeSpanValidator.cs
- Trigger.cs
- MarginsConverter.cs
- StylusSystemGestureEventArgs.cs
- ServiceHttpHandlerFactory.cs
- Font.cs
- Configuration.cs
- ChtmlImageAdapter.cs
- MembershipUser.cs
- HttpConfigurationContext.cs
- Slider.cs
- PathStreamGeometryContext.cs
- TypeConverter.cs
- LoginView.cs
- OleStrCAMarshaler.cs
- SequenceDesigner.cs
- FontConverter.cs
- AddInAdapter.cs
- StorageConditionPropertyMapping.cs
- ValidationManager.cs
- FormViewRow.cs
- ListViewPagedDataSource.cs
- DesignerHierarchicalDataSourceView.cs
- WebEventCodes.cs
- InfoCardBaseException.cs
- Panel.cs
- ProxyHwnd.cs
- ParseChildrenAsPropertiesAttribute.cs
- CodeDelegateCreateExpression.cs
- HandleCollector.cs
- WebPartMinimizeVerb.cs
- EventSinkHelperWriter.cs
- MDIClient.cs
- rsa.cs
- TripleDESCryptoServiceProvider.cs
- Viewport3DAutomationPeer.cs
- SqlDataSourceView.cs
- XmlWriterTraceListener.cs
- ActivityCollectionMarkupSerializer.cs
- DictionarySectionHandler.cs
- SoapExtension.cs
- ToolStripPanelRow.cs
- NotCondition.cs
- SecurityDocument.cs