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 / StaticExtensionConverter.cs / 1 / StaticExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: StaticExtensionConverter.cs // // Contents: Converter to convert StaticExtensions 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 StaticExtensionConverter : 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 StaticExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { StaticExtension staticExtension = value as StaticExtension; if (staticExtension == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension")); return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), new object[] { staticExtension.Member }); } 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: StaticExtensionConverter.cs // // Contents: Converter to convert StaticExtensions 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 StaticExtensionConverter : 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 StaticExtension, not an arbitrary class /// [SecurityCritical, SecurityTreatAsSafe] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { StaticExtension staticExtension = value as StaticExtension; if (staticExtension == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension")); return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), new object[] { staticExtension.Member }); } 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
- CodeAccessSecurityEngine.cs
- TextAutomationPeer.cs
- PageHandlerFactory.cs
- DataProtectionSecurityStateEncoder.cs
- BoolExpression.cs
- EncodingTable.cs
- XmlILCommand.cs
- CheckBoxList.cs
- ControlEvent.cs
- CodeLabeledStatement.cs
- MimeTypePropertyAttribute.cs
- GenericsInstances.cs
- ConnectionManagementElement.cs
- TreeNodeStyle.cs
- IntermediatePolicyValidator.cs
- DateTimeFormatInfoScanner.cs
- ChannelBinding.cs
- WmiEventSink.cs
- MetadataPropertyvalue.cs
- TreeViewImageKeyConverter.cs
- XmlUnspecifiedAttribute.cs
- EDesignUtil.cs
- XsdDuration.cs
- SchemaElement.cs
- Menu.cs
- WaitHandleCannotBeOpenedException.cs
- Baml2006ReaderFrame.cs
- KeyValueConfigurationElement.cs
- AdPostCacheSubstitution.cs
- HMACMD5.cs
- Rijndael.cs
- AsymmetricSignatureFormatter.cs
- VarInfo.cs
- TableLayoutSettings.cs
- SqlExpressionNullability.cs
- ErrorTableItemStyle.cs
- CustomValidator.cs
- UpdateEventArgs.cs
- TableLayoutStyle.cs
- TypeLoadException.cs
- DetailsViewRow.cs
- GcSettings.cs
- Config.cs
- ContentIterators.cs
- SQLInt16Storage.cs
- TextTreeFixupNode.cs
- StatusBarAutomationPeer.cs
- PrivilegedConfigurationManager.cs
- OutgoingWebRequestContext.cs
- RuntimeWrappedException.cs
- WebPartUserCapability.cs
- ISFTagAndGuidCache.cs
- ConversionContext.cs
- PageContentCollection.cs
- QueryCacheManager.cs
- AccessibleObject.cs
- Point3DAnimationUsingKeyFrames.cs
- ServicePointManager.cs
- ItemsPresenter.cs
- Stroke.cs
- ProfilePropertySettingsCollection.cs
- PrePostDescendentsWalker.cs
- DropShadowEffect.cs
- FixedStringLookup.cs
- WindowsScrollBarBits.cs
- SmiContext.cs
- FileVersion.cs
- WebConfigurationHost.cs
- ExpressionConverter.cs
- securestring.cs
- PageCache.cs
- SessionPageStateSection.cs
- SqlConnectionPoolProviderInfo.cs
- KeyValueInternalCollection.cs
- documentsequencetextview.cs
- PanelStyle.cs
- ModelEditingScope.cs
- RenderDataDrawingContext.cs
- TableDetailsCollection.cs
- SqlLiftIndependentRowExpressions.cs
- UIElement.cs
- GroupAggregateExpr.cs
- SourceElementsCollection.cs
- ListItemConverter.cs
- XMLSyntaxException.cs
- SQlBooleanStorage.cs
- COM2Enum.cs
- MeasurementDCInfo.cs
- SiteMapSection.cs
- RemotingConfiguration.cs
- XmlQualifiedNameTest.cs
- XmlDataSourceView.cs
- XmlTextReaderImpl.cs
- SystemEvents.cs
- OleDbDataReader.cs
- View.cs
- MethodToken.cs
- Parsers.cs
- TableRow.cs
- CodeAttachEventStatement.cs