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
- TagMapInfo.cs
- WindowsNonControl.cs
- StackOverflowException.cs
- ArrayTypeMismatchException.cs
- GridPattern.cs
- ResourceAssociationType.cs
- ToolStripItemCollection.cs
- DefaultPrintController.cs
- NominalTypeEliminator.cs
- DataError.cs
- SystemParameters.cs
- Model3DCollection.cs
- GridViewColumnCollectionChangedEventArgs.cs
- CacheDependency.cs
- Membership.cs
- ListControlBuilder.cs
- SocketStream.cs
- SynchronizingStream.cs
- UpnEndpointIdentityExtension.cs
- DataSysAttribute.cs
- EncryptedKey.cs
- XamlToRtfWriter.cs
- ToolStripDropDown.cs
- ProfileWorkflowElement.cs
- Utility.cs
- DataQuery.cs
- ConnectionManagementSection.cs
- LinkLabelLinkClickedEvent.cs
- WebPartZoneBase.cs
- CheckBoxAutomationPeer.cs
- EdmToObjectNamespaceMap.cs
- ButtonRenderer.cs
- Stylesheet.cs
- DataPagerCommandEventArgs.cs
- ItemList.cs
- XsdDuration.cs
- MetadataItemSerializer.cs
- DataGridTableCollection.cs
- InputBuffer.cs
- ComPlusSynchronizationContext.cs
- DirectoryRootQuery.cs
- DiffuseMaterial.cs
- TimeSpanParse.cs
- EnumValAlphaComparer.cs
- TextOnlyOutput.cs
- HtmlAnchor.cs
- TypeToken.cs
- FixedTextView.cs
- ExpressionConverter.cs
- UserCancellationException.cs
- AdornerHitTestResult.cs
- ActivityExecutorOperation.cs
- NavigationPropertyEmitter.cs
- MouseEventArgs.cs
- UnmanagedHandle.cs
- RequestBringIntoViewEventArgs.cs
- SQLRoleProvider.cs
- EntityDataSourceSelectingEventArgs.cs
- CompressEmulationStream.cs
- TemplateControl.cs
- PartialCachingControl.cs
- EncoderReplacementFallback.cs
- PermissionSet.cs
- StateRuntime.cs
- DbgCompiler.cs
- Oci.cs
- Hashtable.cs
- KeyValuePairs.cs
- TileModeValidation.cs
- XmlAnyElementAttributes.cs
- EventLogger.cs
- CryptoProvider.cs
- ThumbButtonInfo.cs
- BamlWriter.cs
- GroupStyle.cs
- CounterSampleCalculator.cs
- WinFormsUtils.cs
- SamlSecurityToken.cs
- VisualStyleInformation.cs
- SqlRowUpdatedEvent.cs
- WebZone.cs
- CompleteWizardStep.cs
- MenuItemCollectionEditor.cs
- DetailsViewRowCollection.cs
- MethodBody.cs
- Helpers.cs
- WhereQueryOperator.cs
- NullableDoubleAverageAggregationOperator.cs
- ObjectQueryExecutionPlan.cs
- ProgressBarRenderer.cs
- XPathConvert.cs
- mactripleDES.cs
- VisualStateGroup.cs
- CodeDOMProvider.cs
- XmlSerializerObjectSerializer.cs
- BitmapEffectGeneralTransform.cs
- PresentationAppDomainManager.cs
- Drawing.cs
- UInt64.cs
- ToggleProviderWrapper.cs