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 / Markup / StaticExtensionConverter.cs / 1 / StaticExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: StaticExtensionConverter.cs // // Contents: Converter to convert StaticExtensions to InstanceDescriptors // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections.Generic; using System.Text; using System.Security; namespace System.Windows.Markup { class StaticExtensionConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// TreatAsSafe: can only make an InstanceDescriptor for StaticExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { StaticExtension staticExtension = value as StaticExtension; if (staticExtension == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension")); return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), new object[] { staticExtension.Member }); } 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: StaticExtensionConverter.cs // // Contents: Converter to convert StaticExtensions to InstanceDescriptors // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections.Generic; using System.Text; using System.Security; namespace System.Windows.Markup { class StaticExtensionConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// TreatAsSafe: can only make an InstanceDescriptor for StaticExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { StaticExtension staticExtension = value as StaticExtension; if (staticExtension == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension")); return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), new object[] { staticExtension.Member }); } 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
- NativeMethods.cs
- EncryptedKey.cs
- RelatedImageListAttribute.cs
- Font.cs
- SiblingIterators.cs
- BitmapEffectDrawingContent.cs
- SubMenuStyleCollection.cs
- ProxyWebPartManager.cs
- DigitalSignatureProvider.cs
- ZipFileInfoCollection.cs
- WebSysDisplayNameAttribute.cs
- CollectionEditVerbManager.cs
- ItemContainerProviderWrapper.cs
- XmlNavigatorStack.cs
- loginstatus.cs
- CodeCommentStatementCollection.cs
- CompositeFontFamily.cs
- FileSystemEnumerable.cs
- ParseChildrenAsPropertiesAttribute.cs
- PkcsMisc.cs
- nulltextnavigator.cs
- MimeTypePropertyAttribute.cs
- CompilerState.cs
- UserNameSecurityTokenProvider.cs
- RequestQueryParser.cs
- InputScope.cs
- FlowLayout.cs
- DocumentPageHost.cs
- ProtocolsConfigurationHandler.cs
- TrustManager.cs
- SqlGatherConsumedAliases.cs
- DesignerAttribute.cs
- XmlRootAttribute.cs
- InheritanceContextHelper.cs
- PageAsyncTaskManager.cs
- DataGridViewRowsAddedEventArgs.cs
- HandleTable.cs
- validationstate.cs
- SQLInt16.cs
- ChtmlTextWriter.cs
- arabicshape.cs
- DocumentViewerBaseAutomationPeer.cs
- UrlMappingCollection.cs
- FixedSOMTableRow.cs
- LogRecordSequence.cs
- EntityEntry.cs
- ToolStripStatusLabel.cs
- CollectionConverter.cs
- MediaPlayer.cs
- SingleTagSectionHandler.cs
- WebPartZoneCollection.cs
- BulletedList.cs
- SendActivityValidator.cs
- EventLogPermissionEntry.cs
- CompiledQuery.cs
- LinkUtilities.cs
- GenericQueueSurrogate.cs
- DataGridViewTopRowAccessibleObject.cs
- Comparer.cs
- PenThreadWorker.cs
- PopupControlService.cs
- SplitterCancelEvent.cs
- TypeForwardedToAttribute.cs
- documentsequencetextpointer.cs
- StorageFunctionMapping.cs
- EntityParameter.cs
- ResourceDescriptionAttribute.cs
- DataServiceConfiguration.cs
- TableLayoutSettingsTypeConverter.cs
- MessageBodyMemberAttribute.cs
- DesignerCategoryAttribute.cs
- Triplet.cs
- arabicshape.cs
- WCFBuildProvider.cs
- MeasureData.cs
- PolicyUtility.cs
- DropDownList.cs
- Helper.cs
- CodeDomSerializer.cs
- WebDescriptionAttribute.cs
- DesigntimeLicenseContextSerializer.cs
- Latin1Encoding.cs
- PropertyInformationCollection.cs
- ScriptComponentDescriptor.cs
- GroupStyle.cs
- DataColumnMappingCollection.cs
- PersistenceTypeAttribute.cs
- OlePropertyStructs.cs
- PrinterSettings.cs
- XsltQilFactory.cs
- ColumnResult.cs
- SendMailErrorEventArgs.cs
- HeaderLabel.cs
- EventLogEntry.cs
- SRef.cs
- InheritablePropertyChangeInfo.cs
- QueryAccessibilityHelpEvent.cs
- WebPartEventArgs.cs
- AnnotationHelper.cs
- CuspData.cs