Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- _SSPISessionCache.cs
- RestClientProxyHandler.cs
- CreateParams.cs
- ComPlusTypeValidator.cs
- AppDomainAttributes.cs
- AlgoModule.cs
- WebPartAddingEventArgs.cs
- DataContractJsonSerializer.cs
- GAC.cs
- COSERVERINFO.cs
- mactripleDES.cs
- VSWCFServiceContractGenerator.cs
- PackageFilter.cs
- MemberInfoSerializationHolder.cs
- SqlUdtInfo.cs
- XmlTextEncoder.cs
- RowUpdatedEventArgs.cs
- HttpConfigurationSystem.cs
- RoleGroupCollection.cs
- MultilineStringConverter.cs
- TdsParserStateObject.cs
- ComponentFactoryHelpers.cs
- CodeGenerator.cs
- ForwardPositionQuery.cs
- SurrogateSelector.cs
- SqlTriggerAttribute.cs
- RecognitionEventArgs.cs
- StackBuilderSink.cs
- CachedFontFamily.cs
- ObjectListCommandCollection.cs
- AppearanceEditorPart.cs
- TabPage.cs
- TextEncodedRawTextWriter.cs
- TileModeValidation.cs
- DeclarativeCatalogPartDesigner.cs
- BuilderPropertyEntry.cs
- SqlUtils.cs
- LineProperties.cs
- RectangleF.cs
- SystemUnicastIPAddressInformation.cs
- TextRange.cs
- httpapplicationstate.cs
- GAC.cs
- BinaryKeyIdentifierClause.cs
- PenLineCapValidation.cs
- _UncName.cs
- DisplayMemberTemplateSelector.cs
- Module.cs
- CriticalExceptions.cs
- ISAPIApplicationHost.cs
- CookieParameter.cs
- CommandLibraryHelper.cs
- Attachment.cs
- Pipe.cs
- SafeMarshalContext.cs
- AQNBuilder.cs
- ButtonBaseAutomationPeer.cs
- XamlTypeMapper.cs
- DataRelation.cs
- DoubleLink.cs
- CustomAttributeFormatException.cs
- XPathLexer.cs
- FormsAuthenticationConfiguration.cs
- SmiContext.cs
- HttpConfigurationSystem.cs
- EventLogPermissionEntryCollection.cs
- SafeViewOfFileHandle.cs
- RoleManagerSection.cs
- BinaryConverter.cs
- PairComparer.cs
- FormViewPageEventArgs.cs
- WizardPanelChangingEventArgs.cs
- InstancePersistenceException.cs
- BitmapEffectState.cs
- TraceUtils.cs
- CurrencyManager.cs
- IndicCharClassifier.cs
- ClipboardData.cs
- ExpressionVisitorHelpers.cs
- MouseGesture.cs
- ProfileProvider.cs
- XsdBuildProvider.cs
- GregorianCalendarHelper.cs
- ECDiffieHellmanPublicKey.cs
- updatecommandorderer.cs
- BezierSegment.cs
- WeakReferenceEnumerator.cs
- ActivitySurrogateSelector.cs
- Accessible.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- MatrixKeyFrameCollection.cs
- ResourcePart.cs
- MailSettingsSection.cs
- PermissionSetTriple.cs
- DiscoveryReferences.cs
- PackWebRequest.cs
- BindStream.cs
- ReversePositionQuery.cs
- ToRequest.cs
- AlternateView.cs