Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- DerivedKeySecurityTokenStub.cs
- HtmlContainerControl.cs
- TabControlEvent.cs
- GeneralTransform3DTo2DTo3D.cs
- DbExpressionVisitor.cs
- CorrelationManager.cs
- ToolStripCollectionEditor.cs
- PropertyCondition.cs
- Wrapper.cs
- TcpAppDomainProtocolHandler.cs
- QuaternionRotation3D.cs
- MaskedTextProvider.cs
- CultureInfoConverter.cs
- PathTooLongException.cs
- CacheDependency.cs
- XamlToRtfParser.cs
- EditorPartCollection.cs
- HttpAsyncResult.cs
- MoveSizeWinEventHandler.cs
- OSFeature.cs
- ApplyHostConfigurationBehavior.cs
- ReadOnlyHierarchicalDataSource.cs
- SoapConverter.cs
- ByeMessageApril2005.cs
- Point.cs
- Queue.cs
- ClientSection.cs
- path.cs
- VariableReference.cs
- HttpMethodConstraint.cs
- CompositeScriptReference.cs
- HWStack.cs
- DataGridViewCellFormattingEventArgs.cs
- MembershipSection.cs
- MappingException.cs
- MsmqIntegrationSecurity.cs
- UnmanagedBitmapWrapper.cs
- OleDbConnection.cs
- SoapInteropTypes.cs
- BeginSelectCardRequest.cs
- TimelineCollection.cs
- NameValuePermission.cs
- SqlClientMetaDataCollectionNames.cs
- EventLogEntryCollection.cs
- SQLInt64Storage.cs
- WebConfigurationHostFileChange.cs
- SignedPkcs7.cs
- SafeHandles.cs
- GridViewCommandEventArgs.cs
- Size3DConverter.cs
- LinkButton.cs
- ObjectDataSourceView.cs
- SettingsPropertyValueCollection.cs
- WebContext.cs
- UriParserTemplates.cs
- MetadataUtil.cs
- ItemTypeToolStripMenuItem.cs
- AccessorTable.cs
- CryptoHelper.cs
- CategoryEditor.cs
- EqualityComparer.cs
- TagPrefixInfo.cs
- UserPreferenceChangingEventArgs.cs
- WebPartMenu.cs
- FieldToken.cs
- ExceptionHandlersDesigner.cs
- SQLInt32.cs
- _ContextAwareResult.cs
- DateRangeEvent.cs
- SqlDataSourceQuery.cs
- CompositeScriptReference.cs
- EmptyEnumerator.cs
- Stopwatch.cs
- DataErrorValidationRule.cs
- Roles.cs
- ClientUtils.cs
- DependencySource.cs
- XmlSchemaValidator.cs
- XmlSchemaSimpleTypeRestriction.cs
- SoapCodeExporter.cs
- SmtpNetworkElement.cs
- ListManagerBindingsCollection.cs
- PropertyMap.cs
- RequestSecurityTokenResponseCollection.cs
- CellNormalizer.cs
- DataColumnMapping.cs
- NavigationPropertyEmitter.cs
- Codec.cs
- ContextStack.cs
- PointAnimationBase.cs
- XmlArrayItemAttributes.cs
- RequiredFieldValidator.cs
- DbDataAdapter.cs
- TagMapInfo.cs
- HttpModuleActionCollection.cs
- TextFindEngine.cs
- MtomMessageEncoder.cs
- PageParser.cs
- HttpStreamMessage.cs
- RichTextBoxConstants.cs