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
- TypedAsyncResult.cs
- StreamInfo.cs
- RowToParametersTransformer.cs
- ProcessModelSection.cs
- SeparatorAutomationPeer.cs
- CaseInsensitiveHashCodeProvider.cs
- DesigntimeLicenseContextSerializer.cs
- DataObjectSettingDataEventArgs.cs
- WebBrowserNavigatingEventHandler.cs
- WebBrowserBase.cs
- Annotation.cs
- XmlSchemaSimpleTypeUnion.cs
- UrlMapping.cs
- AssemblyAssociatedContentFileAttribute.cs
- EventMappingSettings.cs
- StandardCommands.cs
- EventTrigger.cs
- RayMeshGeometry3DHitTestResult.cs
- CqlErrorHelper.cs
- regiisutil.cs
- CaseCqlBlock.cs
- ObjectContext.cs
- StylusEventArgs.cs
- StyleBamlRecordReader.cs
- OdbcConnectionPoolProviderInfo.cs
- EngineSiteSapi.cs
- ToolstripProfessionalRenderer.cs
- MetadataItemEmitter.cs
- SQLBoolean.cs
- MinimizableAttributeTypeConverter.cs
- StickyNoteContentControl.cs
- OutputBuffer.cs
- HashStream.cs
- ExpressionBuilder.cs
- DbXmlEnabledProviderManifest.cs
- CachedCompositeFamily.cs
- EnumValAlphaComparer.cs
- SBCSCodePageEncoding.cs
- AssociatedControlConverter.cs
- EventLogEntry.cs
- GlobalAllocSafeHandle.cs
- WebBrowsableAttribute.cs
- RowSpanVector.cs
- SuppressMergeCheckAttribute.cs
- Parser.cs
- SqlDataReader.cs
- TypeDescriptionProviderAttribute.cs
- AttributeUsageAttribute.cs
- VSDExceptions.cs
- DiagnosticsConfiguration.cs
- WindowsTooltip.cs
- NamespaceDecl.cs
- SqlDataSourceCache.cs
- PipelineModuleStepContainer.cs
- FlowLayoutSettings.cs
- CustomSignedXml.cs
- ColorConvertedBitmap.cs
- NameSpaceEvent.cs
- EmbeddedObject.cs
- ArraySegment.cs
- Condition.cs
- DataSourceCache.cs
- MessageSmuggler.cs
- TextModifierScope.cs
- ScriptManager.cs
- IPPacketInformation.cs
- CodeAssignStatement.cs
- GridViewUpdatedEventArgs.cs
- XmlUnspecifiedAttribute.cs
- FontResourceCache.cs
- PersonalizationStateInfo.cs
- SafeNativeMethods.cs
- ContainerUtilities.cs
- DataGridViewImageCell.cs
- ChoiceConverter.cs
- Timer.cs
- TransformerConfigurationWizardBase.cs
- ValidatorCompatibilityHelper.cs
- NameValueCollection.cs
- DesignTimeTemplateParser.cs
- DependencyObject.cs
- PropertyFilterAttribute.cs
- DeclaredTypeElementCollection.cs
- TypeGeneratedEventArgs.cs
- WindowsAuthenticationModule.cs
- PointCollection.cs
- RadioButtonRenderer.cs
- InstanceDataCollectionCollection.cs
- DictionaryBase.cs
- Compiler.cs
- DefaultCommandConverter.cs
- ping.cs
- MultiPageTextView.cs
- ScriptResourceInfo.cs
- DbConnectionPoolGroupProviderInfo.cs
- SocketInformation.cs
- InstanceStore.cs
- IUnknownConstantAttribute.cs
- DataObject.cs
- EventLogPermission.cs