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
- TemplateXamlParser.cs
- ReferenceTypeElement.cs
- ApplicationProxyInternal.cs
- ResumeStoryboard.cs
- TreeView.cs
- XmlEventCache.cs
- HotCommands.cs
- AuthenticationModuleElement.cs
- MemberDescriptor.cs
- RegionInfo.cs
- EntityCommandExecutionException.cs
- ItemsPresenter.cs
- BufferedGraphicsContext.cs
- ForAllOperator.cs
- BStrWrapper.cs
- GlobalItem.cs
- MeshGeometry3D.cs
- ObjectDisposedException.cs
- ByteKeyFrameCollection.cs
- TriggerBase.cs
- SupportedAddressingMode.cs
- MouseButtonEventArgs.cs
- CompareValidator.cs
- SchemaEntity.cs
- x509store.cs
- PropertyPathConverter.cs
- DataGridViewDataConnection.cs
- TemplateManager.cs
- XsltQilFactory.cs
- BinaryWriter.cs
- SchemaNamespaceManager.cs
- IconHelper.cs
- Int32Rect.cs
- TextEditorSpelling.cs
- TextBoxBase.cs
- Point3DAnimationUsingKeyFrames.cs
- OpenTypeLayoutCache.cs
- XsltContext.cs
- DeviceContext.cs
- ProcessThreadCollection.cs
- SendAgentStatusRequest.cs
- PlatformNotSupportedException.cs
- SchemaImporterExtensionElementCollection.cs
- CodeCastExpression.cs
- Vector3DAnimationUsingKeyFrames.cs
- SHA512.cs
- TraceUtility.cs
- TypedElement.cs
- PersistenceContextEnlistment.cs
- _ShellExpression.cs
- ProvideValueServiceProvider.cs
- WebPartEditorOkVerb.cs
- HostedNamedPipeTransportManager.cs
- DrawingContextFlattener.cs
- SynchronizedDispatch.cs
- UniqueContractNameValidationBehavior.cs
- TableLayoutRowStyleCollection.cs
- Int32EqualityComparer.cs
- StringUtil.cs
- ActivityExecutorDelegateInfo.cs
- XmlSchemaChoice.cs
- ProcessHostFactoryHelper.cs
- AutomationPeer.cs
- DataGridCellsPanel.cs
- SqlMethodAttribute.cs
- InputScopeManager.cs
- RotateTransform.cs
- PathFigure.cs
- TextSelectionProcessor.cs
- StatusBar.cs
- IteratorDescriptor.cs
- SafePEFileHandle.cs
- MemoryRecordBuffer.cs
- NumericPagerField.cs
- RichTextBox.cs
- StylusButtonCollection.cs
- InlineCollection.cs
- SymbolEqualComparer.cs
- PathFigureCollectionConverter.cs
- CustomLineCap.cs
- RepeatBehaviorConverter.cs
- ListViewUpdateEventArgs.cs
- DrawingAttributeSerializer.cs
- SQLDouble.cs
- SpellerInterop.cs
- SoapSchemaImporter.cs
- BinHexEncoder.cs
- Version.cs
- MarkupWriter.cs
- ComponentEvent.cs
- DataServiceQuery.cs
- SemaphoreSecurity.cs
- SpecialFolderEnumConverter.cs
- BufferedWebEventProvider.cs
- LOSFormatter.cs
- ExpressionPrefixAttribute.cs
- ListItem.cs
- TimeoutValidationAttribute.cs
- HttpPostedFile.cs
- X509CertificateCollection.cs