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
- TimeZone.cs
- RemoteWebConfigurationHostStream.cs
- MemberDescriptor.cs
- PropertyFilterAttribute.cs
- SQLDateTime.cs
- COM2Properties.cs
- GridSplitter.cs
- DocumentGrid.cs
- XmlHierarchicalDataSourceView.cs
- IssuedTokenParametersElement.cs
- ItemDragEvent.cs
- TryLoadRunnableWorkflowCommand.cs
- HTMLTagNameToTypeMapper.cs
- DoubleCollection.cs
- XPathException.cs
- ListViewItem.cs
- DependencyPropertyKey.cs
- StructuralCache.cs
- XmlCharacterData.cs
- ObjectDisposedException.cs
- AdRotatorDesigner.cs
- TextServicesCompartmentEventSink.cs
- ProxyWebPart.cs
- ItemCollection.cs
- TableCellCollection.cs
- UrlAuthFailedErrorFormatter.cs
- SqlConnection.cs
- ToolStripPanelCell.cs
- NumericExpr.cs
- HMACSHA384.cs
- LinearKeyFrames.cs
- Graphics.cs
- StateDesignerConnector.cs
- EventMappingSettingsCollection.cs
- HitTestDrawingContextWalker.cs
- RuntimeResourceSet.cs
- EasingFunctionBase.cs
- ProfileServiceManager.cs
- SpecialFolderEnumConverter.cs
- HitTestParameters3D.cs
- ApplicationProxyInternal.cs
- codemethodreferenceexpression.cs
- ToggleProviderWrapper.cs
- PropertyItemInternal.cs
- X509UI.cs
- OletxDependentTransaction.cs
- ReflectionServiceProvider.cs
- NodeCounter.cs
- LongSumAggregationOperator.cs
- Crc32.cs
- MetadataArtifactLoaderComposite.cs
- HtmlForm.cs
- ProvidersHelper.cs
- CodeEntryPointMethod.cs
- ObjectSpanRewriter.cs
- CachedBitmap.cs
- ClientConfigurationSystem.cs
- ScrollBar.cs
- UserControlCodeDomTreeGenerator.cs
- InstancePersistenceContext.cs
- Matrix.cs
- MatrixStack.cs
- DataServiceQuery.cs
- BindingOperations.cs
- DefinitionBase.cs
- ReleaseInstanceMode.cs
- EmptyCollection.cs
- OLEDB_Enum.cs
- WebPartHelpVerb.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- KeyEvent.cs
- WebPartDeleteVerb.cs
- SinglePageViewer.cs
- CompositeFontFamily.cs
- DataGridViewColumn.cs
- SqlLiftIndependentRowExpressions.cs
- ObjectPropertyMapping.cs
- Block.cs
- ConfigXmlWhitespace.cs
- VisemeEventArgs.cs
- ExpressionWriter.cs
- HttpCapabilitiesSectionHandler.cs
- RuleAction.cs
- EntityModelSchemaGenerator.cs
- FlowDecisionLabelFeature.cs
- Journaling.cs
- DataBinding.cs
- SplineKeyFrames.cs
- MouseDevice.cs
- VirtualizingStackPanel.cs
- StringKeyFrameCollection.cs
- XmlFormatReaderGenerator.cs
- RotateTransform.cs
- ThaiBuddhistCalendar.cs
- SerializationAttributes.cs
- ResourceContainer.cs
- ConfigXmlCDataSection.cs
- OdbcEnvironmentHandle.cs
- Evidence.cs
- GridViewAutomationPeer.cs