Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- NetPipeSection.cs
- ParameterCollection.cs
- Bezier.cs
- ProviderSettingsCollection.cs
- AttributeAction.cs
- Camera.cs
- CharacterBufferReference.cs
- VisualTreeUtils.cs
- AttributeXamlType.cs
- XmlTextEncoder.cs
- ConsumerConnectionPointCollection.cs
- DataGridViewHeaderCell.cs
- WebPartConnectionsCancelVerb.cs
- SchemaReference.cs
- ByteStack.cs
- PageHandlerFactory.cs
- AnnotationHelper.cs
- PictureBox.cs
- MediaEntryAttribute.cs
- ErrorReporting.cs
- TimeSpanMinutesConverter.cs
- EtwTrace.cs
- Section.cs
- DataServiceHostFactory.cs
- WindowPattern.cs
- SqlError.cs
- ObjectPropertyMapping.cs
- AssemblyResourceLoader.cs
- SetIterators.cs
- ReadOnlyHierarchicalDataSourceView.cs
- CacheModeConverter.cs
- ProtocolsConfigurationHandler.cs
- HtmlInputControl.cs
- SelectionEditingBehavior.cs
- ColorInterpolationModeValidation.cs
- elementinformation.cs
- NetDataContractSerializer.cs
- DataSourceHelper.cs
- NativeMethods.cs
- DesignerUtility.cs
- TableItemProviderWrapper.cs
- ToolConsole.cs
- EntityDesignerBuildProvider.cs
- HttpResponse.cs
- CacheChildrenQuery.cs
- TargetPerspective.cs
- BorderGapMaskConverter.cs
- RectAnimationBase.cs
- ExecutedRoutedEventArgs.cs
- NamedElement.cs
- ConfigXmlSignificantWhitespace.cs
- LifetimeServices.cs
- GenericTypeParameterBuilder.cs
- Color.cs
- QilReference.cs
- Point3DCollection.cs
- MenuItemStyleCollection.cs
- StreamUpdate.cs
- FunctionCommandText.cs
- FaultReasonText.cs
- SoapClientMessage.cs
- PresentationAppDomainManager.cs
- CellParaClient.cs
- XamlFrame.cs
- DefaultValueTypeConverter.cs
- BitmapSource.cs
- GC.cs
- OutOfMemoryException.cs
- PageAdapter.cs
- DbXmlEnabledProviderManifest.cs
- _Events.cs
- HoistedLocals.cs
- ValidateNames.cs
- OleDbCommand.cs
- UseAttributeSetsAction.cs
- ColorConvertedBitmap.cs
- SerializerDescriptor.cs
- ListParagraph.cs
- Literal.cs
- SerializationObjectManager.cs
- DataSourceSerializationException.cs
- DataViewSettingCollection.cs
- BindingContext.cs
- SoapInteropTypes.cs
- DataReceivedEventArgs.cs
- COAUTHINFO.cs
- EntityRecordInfo.cs
- QfeChecker.cs
- HtmlTableRow.cs
- AudioLevelUpdatedEventArgs.cs
- DbProviderSpecificTypePropertyAttribute.cs
- WebPartEditorApplyVerb.cs
- HtmlTernaryTree.cs
- _CookieModule.cs
- XmlReflectionMember.cs
- CompiledAction.cs
- VisualStyleElement.cs
- diagnosticsswitches.cs
- ExpressionDumper.cs
- DrawingContext.cs