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
- CustomAttributeSerializer.cs
- HttpApplicationFactory.cs
- AdCreatedEventArgs.cs
- UnitControl.cs
- CatalogPart.cs
- RuleInfoComparer.cs
- WebPartEditorCancelVerb.cs
- HierarchicalDataSourceDesigner.cs
- MulticastDelegate.cs
- Membership.cs
- DrawingCollection.cs
- ArgumentReference.cs
- MediaContext.cs
- EndpointNotFoundException.cs
- TypeDelegator.cs
- SqlEnums.cs
- ParserOptions.cs
- PersonalizationProvider.cs
- RankException.cs
- Calendar.cs
- CacheChildrenQuery.cs
- cookiecontainer.cs
- WebServiceResponse.cs
- DbgUtil.cs
- Bezier.cs
- SystemTcpStatistics.cs
- RegularExpressionValidator.cs
- OperationPickerDialog.designer.cs
- XmlDesignerDataSourceView.cs
- Journaling.cs
- ObjectCacheSettings.cs
- SetStoryboardSpeedRatio.cs
- AuthorizationRule.cs
- DesignerAdapterUtil.cs
- ConditionalDesigner.cs
- Utils.cs
- UrlAuthorizationModule.cs
- CodeCompiler.cs
- BitmapEffectGroup.cs
- ToolStripHighContrastRenderer.cs
- CommonObjectSecurity.cs
- TdsParserSafeHandles.cs
- EnumerableWrapperWeakToStrong.cs
- Mapping.cs
- DtdParser.cs
- XmlSchemaSimpleContentRestriction.cs
- HttpRequestTraceRecord.cs
- LineBreak.cs
- HealthMonitoringSection.cs
- CodeTypeDelegate.cs
- SrgsGrammar.cs
- MarkupCompiler.cs
- SchemaNotation.cs
- Grant.cs
- CompiledRegexRunner.cs
- ParseHttpDate.cs
- GraphicsPath.cs
- Version.cs
- QilInvokeEarlyBound.cs
- TrackingMemoryStreamFactory.cs
- WrappingXamlSchemaContext.cs
- CodeFieldReferenceExpression.cs
- Unit.cs
- ColorConvertedBitmap.cs
- ResourcePermissionBase.cs
- validation.cs
- Attributes.cs
- FilteredDataSetHelper.cs
- AutoCompleteStringCollection.cs
- SelectedDatesCollection.cs
- RuntimeIdentifierPropertyAttribute.cs
- Internal.cs
- ScrollBar.cs
- HotSpot.cs
- ServiceProviders.cs
- ListViewGroupConverter.cs
- WSHttpBinding.cs
- InterleavedZipPartStream.cs
- CustomErrorCollection.cs
- XmlQueryContext.cs
- PipelineComponent.cs
- DragEvent.cs
- ErrorWrapper.cs
- DefaultValueTypeConverter.cs
- WebPartRestoreVerb.cs
- BinaryObjectInfo.cs
- FastEncoder.cs
- xml.cs
- TypedReference.cs
- Rotation3DAnimationUsingKeyFrames.cs
- Style.cs
- Rect.cs
- WindowsToolbarItemAsMenuItem.cs
- TextSelection.cs
- TrailingSpaceComparer.cs
- ObjectStateEntry.cs
- NameHandler.cs
- RegexEditorDialog.cs
- IndexedEnumerable.cs
- COM2Properties.cs