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
- ManagedIStream.cs
- Visual3D.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- RandomNumberGenerator.cs
- ResXFileRef.cs
- ResourceAttributes.cs
- EmptyEnumerator.cs
- XmlBindingWorker.cs
- LoginView.cs
- Stack.cs
- SaveRecipientRequest.cs
- DateTimePickerDesigner.cs
- TemplateControlCodeDomTreeGenerator.cs
- Journal.cs
- SqlDataSourceCache.cs
- Command.cs
- PseudoWebRequest.cs
- UnauthorizedWebPart.cs
- KeyboardNavigation.cs
- WithStatement.cs
- ThrowHelper.cs
- WebBaseEventKeyComparer.cs
- Style.cs
- TraceHwndHost.cs
- HttpProcessUtility.cs
- AuthorizationRule.cs
- XXXOnTypeBuilderInstantiation.cs
- PartialClassGenerationTaskInternal.cs
- EpmContentSerializer.cs
- SqlCacheDependencyDatabase.cs
- DocumentSequenceHighlightLayer.cs
- ContractInstanceProvider.cs
- InvalidProgramException.cs
- TaskFormBase.cs
- _SecureChannel.cs
- ButtonField.cs
- RewritingPass.cs
- DataBinding.cs
- ExpressionBindingCollection.cs
- TextElementEnumerator.cs
- ZipIOLocalFileHeader.cs
- DesignerUtils.cs
- CachedBitmap.cs
- IriParsingElement.cs
- FontConverter.cs
- StreamHelper.cs
- DbConnectionPoolIdentity.cs
- DataGridViewColumnConverter.cs
- RadialGradientBrush.cs
- TableAdapterManagerGenerator.cs
- DelegateHelpers.cs
- CodeSubDirectoriesCollection.cs
- AnnotationAuthorChangedEventArgs.cs
- RegexBoyerMoore.cs
- AppDomainEvidenceFactory.cs
- TriggerCollection.cs
- MenuItem.cs
- XmlSchemaInfo.cs
- XmlProcessingInstruction.cs
- PageThemeCodeDomTreeGenerator.cs
- LoginView.cs
- StorageMappingItemCollection.cs
- QueryExecutionOption.cs
- ViewValidator.cs
- TeredoHelper.cs
- RepeaterItem.cs
- SoapAttributeOverrides.cs
- TypefaceMap.cs
- SoapElementAttribute.cs
- DataServiceStreamProviderWrapper.cs
- ConfigurationLockCollection.cs
- ThreadInterruptedException.cs
- HandleInitializationContext.cs
- HtmlControlPersistable.cs
- XmlCompatibilityReader.cs
- MDIControlStrip.cs
- DetailsViewUpdatedEventArgs.cs
- ToolboxItemAttribute.cs
- TextDecorations.cs
- RequestTimeoutManager.cs
- MessageBox.cs
- CultureInfo.cs
- ArrayList.cs
- IsolatedStorageFileStream.cs
- WebPartConnectionsConnectVerb.cs
- BuildProvidersCompiler.cs
- altserialization.cs
- StyleCollection.cs
- X509RawDataKeyIdentifierClause.cs
- ListViewItem.cs
- DbgUtil.cs
- SqlXml.cs
- EntityDataSourceSelectingEventArgs.cs
- Simplifier.cs
- WebResponse.cs
- EntityDataSourceChangedEventArgs.cs
- TableRowCollection.cs
- SendSecurityHeaderElementContainer.cs
- WebExceptionStatus.cs
- NotifyParentPropertyAttribute.cs