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
- CompiledQueryCacheKey.cs
- NoPersistProperty.cs
- UnsafeNativeMethods.cs
- HandlerMappingMemo.cs
- PopupEventArgs.cs
- ClientSettingsStore.cs
- ConfigurationErrorsException.cs
- Number.cs
- RegexCapture.cs
- LogEntrySerialization.cs
- HtmlInputReset.cs
- TextRenderingModeValidation.cs
- ToolStripLocationCancelEventArgs.cs
- ErrorEventArgs.cs
- WasAdminWrapper.cs
- SessionStateContainer.cs
- LambdaCompiler.Lambda.cs
- KoreanLunisolarCalendar.cs
- GeneralTransform3D.cs
- RemotingException.cs
- ConnectionInterfaceCollection.cs
- OracleBoolean.cs
- URL.cs
- XmlUTF8TextWriter.cs
- Version.cs
- RemotingConfiguration.cs
- PassportPrincipal.cs
- CacheSection.cs
- CreateCardRequest.cs
- PartitionResolver.cs
- __Filters.cs
- RegionData.cs
- LinearGradientBrush.cs
- DSGeneratorProblem.cs
- SqlTypeSystemProvider.cs
- StringConverter.cs
- DynamicMetaObjectBinder.cs
- LocalBuilder.cs
- ToolStripSplitButton.cs
- ProjectionQueryOptionExpression.cs
- XPathDocumentNavigator.cs
- DiscoveryVersion.cs
- LayoutEngine.cs
- CopyAction.cs
- TreeNodeClickEventArgs.cs
- VScrollProperties.cs
- ClientFormsAuthenticationCredentials.cs
- QueryStoreStatusRequest.cs
- DocumentCollection.cs
- DataPagerFieldItem.cs
- FolderBrowserDialog.cs
- HttpDigestClientElement.cs
- ListViewSelectEventArgs.cs
- ImmutableAssemblyCacheEntry.cs
- RenderDataDrawingContext.cs
- AnnotationHelper.cs
- BrowserTree.cs
- Style.cs
- NumericUpDownAcceleration.cs
- PageRanges.cs
- RangeValuePatternIdentifiers.cs
- TextureBrush.cs
- PersistenceException.cs
- QueueProcessor.cs
- MultiView.cs
- GridViewColumnCollection.cs
- XmlSerializerSection.cs
- InputManager.cs
- ColumnMapVisitor.cs
- EntityType.cs
- xmlfixedPageInfo.cs
- SrgsRuleRef.cs
- TreeIterator.cs
- KnowledgeBase.cs
- RenderingBiasValidation.cs
- GrammarBuilderDictation.cs
- SqlProviderUtilities.cs
- LocationUpdates.cs
- EntityFunctions.cs
- RequestCacheValidator.cs
- XmlSerializerSection.cs
- AvtEvent.cs
- UiaCoreProviderApi.cs
- InkCanvasAutomationPeer.cs
- ToolStripItemCollection.cs
- ProvideValueServiceProvider.cs
- _StreamFramer.cs
- _ProxyChain.cs
- DisplayInformation.cs
- OSFeature.cs
- DynamicDataManager.cs
- XmlWriterTraceListener.cs
- WebPartZoneAutoFormat.cs
- InputBuffer.cs
- DateTimePicker.cs
- GridViewCellAutomationPeer.cs
- InternalRelationshipCollection.cs
- TreeNodeBindingCollection.cs
- ImageIndexConverter.cs
- WebPartVerbCollection.cs