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
- TextWriter.cs
- StrongTypingException.cs
- LZCodec.cs
- Validator.cs
- ConfigXmlComment.cs
- Subset.cs
- UnsettableComboBox.cs
- UnmanagedMemoryStreamWrapper.cs
- ResourcePool.cs
- RemoteWebConfigurationHost.cs
- IgnoreFlushAndCloseStream.cs
- CodeObject.cs
- RootContext.cs
- PerformanceCounterPermissionAttribute.cs
- InstanceDescriptor.cs
- SR.Designer.cs
- PerformanceCounterPermissionEntryCollection.cs
- ReadOnlyCollectionBase.cs
- ObjectStateEntryDbDataRecord.cs
- XmlRawWriterWrapper.cs
- oledbmetadatacolumnnames.cs
- WebConfigurationManager.cs
- SmiXetterAccessMap.cs
- PersonalizablePropertyEntry.cs
- RijndaelCryptoServiceProvider.cs
- SqlDataSourceQuery.cs
- DataSourceCache.cs
- MimeParameter.cs
- ArrayList.cs
- Sql8ConformanceChecker.cs
- DataSourceXmlSubItemAttribute.cs
- ObjectDataSourceMethodEventArgs.cs
- NoResizeSelectionBorderGlyph.cs
- SafeNativeMethods.cs
- FormatterServices.cs
- StateBag.cs
- MetadataItemCollectionFactory.cs
- DBDataPermissionAttribute.cs
- WebControlAdapter.cs
- TableRowsCollectionEditor.cs
- DrawItemEvent.cs
- SendMailErrorEventArgs.cs
- Deserializer.cs
- ParserHooks.cs
- DBSqlParser.cs
- KeyboardDevice.cs
- TransformerInfo.cs
- GeometryCombineModeValidation.cs
- ValidationErrorCollection.cs
- SessionIDManager.cs
- JoinTreeNode.cs
- PersistenceTypeAttribute.cs
- NavigatorOutput.cs
- AutoCompleteStringCollection.cs
- PenLineCapValidation.cs
- ArgumentOutOfRangeException.cs
- DependentTransaction.cs
- UserPreference.cs
- HttpCapabilitiesEvaluator.cs
- ImageMetadata.cs
- FontStretch.cs
- HtmlInputPassword.cs
- Stylesheet.cs
- MD5.cs
- StateMachineExecutionState.cs
- TrustExchangeException.cs
- MouseButtonEventArgs.cs
- EUCJPEncoding.cs
- RuleValidation.cs
- OleDbException.cs
- DataSourceCacheDurationConverter.cs
- AuthenticatedStream.cs
- httpserverutility.cs
- MachineKeySection.cs
- PreloadedPackages.cs
- ProfileSettingsCollection.cs
- _LocalDataStoreMgr.cs
- TranslateTransform3D.cs
- AdjustableArrowCap.cs
- ProfileParameter.cs
- Command.cs
- InfiniteTimeSpanConverter.cs
- EntityDataSourceWrapperCollection.cs
- ItemCollection.cs
- CustomAttributeSerializer.cs
- DbDeleteCommandTree.cs
- XmlIncludeAttribute.cs
- MenuItemStyleCollection.cs
- OrderedDictionaryStateHelper.cs
- ManageRequest.cs
- SuppressIldasmAttribute.cs
- coordinatorscratchpad.cs
- CFGGrammar.cs
- DictionaryContent.cs
- ColorBlend.cs
- SoapSchemaExporter.cs
- PersianCalendar.cs
- TitleStyle.cs
- TagMapCollection.cs
- ConfigurationSectionGroup.cs