Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / TemplateBindingExtensionConverter.cs / 1305600 / TemplateBindingExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // TemplateBindingExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Windows; using System.Security; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a TemplateBindingExtension from /// an instance. It reports that Property should be used as the first parameter to the constructor. /// public class TemplateBindingExtensionConverter : TypeConverter { ////// Returns true if converting to an InstanceDescriptor /// /// /// ///public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } /// /// Converts to an InstanceDescriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for TemplateBindingExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); TemplateBindingExtension templateBinding = value as TemplateBindingExtension; if(templateBinding == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TemplateBindingExtension"), "value"); return new InstanceDescriptor(typeof(TemplateBindingExtension).GetConstructor(new Type[] { typeof(DependencyProperty) }), new object[] { templateBinding.Property }); } 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: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // TemplateBindingExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Windows; using System.Security; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a TemplateBindingExtension from /// an instance. It reports that Property should be used as the first parameter to the constructor. /// public class TemplateBindingExtensionConverter : TypeConverter { ////// Returns true if converting to an InstanceDescriptor /// /// /// ///public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } /// /// Converts to an InstanceDescriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for TemplateBindingExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); TemplateBindingExtension templateBinding = value as TemplateBindingExtension; if(templateBinding == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "TemplateBindingExtension"), "value"); return new InstanceDescriptor(typeof(TemplateBindingExtension).GetConstructor(new Type[] { typeof(DependencyProperty) }), new object[] { templateBinding.Property }); } 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
- SmtpDigestAuthenticationModule.cs
- LoopExpression.cs
- RelationshipDetailsRow.cs
- ProviderSettingsCollection.cs
- SecurityTokenRequirement.cs
- OdbcParameterCollection.cs
- InstanceHandleReference.cs
- Dynamic.cs
- ComMethodElement.cs
- WorkflowMessageEventArgs.cs
- BindUriHelper.cs
- ServiceErrorHandler.cs
- NavigationPropertyEmitter.cs
- ImmutablePropertyDescriptorGridEntry.cs
- mediapermission.cs
- SHA1.cs
- PersonalizationState.cs
- XmlBoundElement.cs
- SchemaEntity.cs
- ResourceReferenceExpressionConverter.cs
- Label.cs
- MarkupWriter.cs
- WaitHandleCannotBeOpenedException.cs
- Parser.cs
- DataGridViewLayoutData.cs
- ConsoleTraceListener.cs
- FixedLineResult.cs
- XamlTypeMapper.cs
- QuotedStringWriteStateInfo.cs
- EdmFunction.cs
- BitmapEffectCollection.cs
- PlatformCulture.cs
- TrackBarRenderer.cs
- XmlNodeComparer.cs
- TreeNodeBinding.cs
- EditorPartCollection.cs
- XmlDocument.cs
- WebColorConverter.cs
- NameGenerator.cs
- DocumentationServerProtocol.cs
- Transactions.cs
- ProvideValueServiceProvider.cs
- ObjectListItem.cs
- StorageScalarPropertyMapping.cs
- ServiceBuildProvider.cs
- OdbcConnectionHandle.cs
- BasicHttpSecurity.cs
- ObjectCacheSettings.cs
- TableCell.cs
- EndpointBehaviorElement.cs
- ObjectReaderCompiler.cs
- ACL.cs
- dataobject.cs
- SchemaCompiler.cs
- OleDbDataReader.cs
- XpsFontSubsetter.cs
- StyleXamlParser.cs
- StreamGeometry.cs
- ViewKeyConstraint.cs
- FormViewCommandEventArgs.cs
- ColorConvertedBitmap.cs
- TextEffectCollection.cs
- HostingMessageProperty.cs
- HttpProfileBase.cs
- RequestQueryProcessor.cs
- Rotation3D.cs
- diagnosticsswitches.cs
- ComponentEvent.cs
- ControlsConfig.cs
- EventListenerClientSide.cs
- _SSPISessionCache.cs
- WebHttpSecurityElement.cs
- WebConfigurationManager.cs
- ClientBuildManager.cs
- WorkflowViewManager.cs
- SmtpNtlmAuthenticationModule.cs
- Roles.cs
- PropertyInformationCollection.cs
- ConfigXmlText.cs
- ContentElement.cs
- PolicyStatement.cs
- NamespaceEmitter.cs
- ScrollChrome.cs
- ViewGenerator.cs
- Attributes.cs
- Style.cs
- MonthChangedEventArgs.cs
- CellParaClient.cs
- ShaperBuffers.cs
- WebPartZoneCollection.cs
- PriorityRange.cs
- StringComparer.cs
- JoinElimination.cs
- SocketElement.cs
- ValidationError.cs
- RegistryDataKey.cs
- CssClassPropertyAttribute.cs
- DataGridRowAutomationPeer.cs
- CustomValidator.cs
- SynchronizedInputAdaptor.cs