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 / TypeExtensionConverter.cs / 1 / TypeExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: TypeExtensionConverter.cs // // Contents: Converter to convert TypeExtensions 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 TypeExtensionConverter : 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 TypeExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { TypeExtension typeExtension = value as TypeExtension; if (typeExtension == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TypeExtension")); } return new InstanceDescriptor(typeof(TypeExtension).GetConstructor(new Type[] { typeof(Type) }), new object[] { typeExtension.Type }); } 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: TypeExtensionConverter.cs // // Contents: Converter to convert TypeExtensions 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 TypeExtensionConverter : 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 TypeExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { TypeExtension typeExtension = value as TypeExtension; if (typeExtension == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TypeExtension")); } return new InstanceDescriptor(typeof(TypeExtension).GetConstructor(new Type[] { typeof(Type) }), new object[] { typeExtension.Type }); } 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
- DataGridCaption.cs
- DBParameter.cs
- Match.cs
- BinaryFormatter.cs
- PropertyFilterAttribute.cs
- TableAdapterManagerMethodGenerator.cs
- updateconfighost.cs
- BitmapEffectDrawingContextState.cs
- WindowsRebar.cs
- SocketPermission.cs
- FormViewInsertEventArgs.cs
- Property.cs
- GridViewCommandEventArgs.cs
- loginstatus.cs
- UTF32Encoding.cs
- TextServicesHost.cs
- QueryExpression.cs
- AccessDataSource.cs
- View.cs
- loginstatus.cs
- WebConfigurationHost.cs
- UpdateTranslator.cs
- ReaderContextStackData.cs
- WebColorConverter.cs
- FormatterConverter.cs
- LicFileLicenseProvider.cs
- SafeHandle.cs
- ColorInterpolationModeValidation.cs
- AcceleratedTokenProvider.cs
- StylusShape.cs
- HttpCacheParams.cs
- ErrorTableItemStyle.cs
- webeventbuffer.cs
- ValidatingReaderNodeData.cs
- Baml2006ReaderFrame.cs
- XslCompiledTransform.cs
- BuildProvider.cs
- LogicalTreeHelper.cs
- ToolboxItemWrapper.cs
- ActiveXSite.cs
- XmlEntity.cs
- __TransparentProxy.cs
- LayoutInformation.cs
- SpellerStatusTable.cs
- PrintControllerWithStatusDialog.cs
- ToolStripDropDownMenu.cs
- AttributeParameterInfo.cs
- DataGridViewCellLinkedList.cs
- PerfCounterSection.cs
- PeerCollaborationPermission.cs
- Region.cs
- EventRouteFactory.cs
- PseudoWebRequest.cs
- QueryOperator.cs
- KnownTypeAttribute.cs
- FileSecurity.cs
- SecurityContextSecurityToken.cs
- PageOutputQuality.cs
- SliderAutomationPeer.cs
- BatchServiceHost.cs
- returneventsaver.cs
- ColorMatrix.cs
- MemberMaps.cs
- GenericTypeParameterConverter.cs
- XPathAncestorIterator.cs
- LayoutUtils.cs
- SqlReorderer.cs
- VisualCollection.cs
- RSAProtectedConfigurationProvider.cs
- DnsPermission.cs
- VectorAnimationUsingKeyFrames.cs
- PropertyValueUIItem.cs
- CompilerInfo.cs
- XmlNullResolver.cs
- ProfileEventArgs.cs
- SqlClientWrapperSmiStream.cs
- BooleanAnimationBase.cs
- ByteStream.cs
- FormViewPageEventArgs.cs
- DbConnectionPoolGroupProviderInfo.cs
- AssemblyContextControlItem.cs
- XsltArgumentList.cs
- DataGridViewElement.cs
- XsltLoader.cs
- MruCache.cs
- cookiecollection.cs
- DesignTimeVisibleAttribute.cs
- TableLayoutStyleCollection.cs
- Buffer.cs
- GetPageCompletedEventArgs.cs
- InternalConfigConfigurationFactory.cs
- ModifierKeysValueSerializer.cs
- ClickablePoint.cs
- ConfigDefinitionUpdates.cs
- SqlDuplicator.cs
- GridToolTip.cs
- SettingsProviderCollection.cs
- DataControlFieldHeaderCell.cs
- WindowsStartMenu.cs
- SerializerDescriptor.cs