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
- UIElementParagraph.cs
- httpstaticobjectscollection.cs
- HtmlControlPersistable.cs
- Calendar.cs
- OdbcRowUpdatingEvent.cs
- RegisteredScript.cs
- CorrelationResolver.cs
- SmiContextFactory.cs
- BlurEffect.cs
- EmptyEnumerator.cs
- StreamGeometryContext.cs
- FactoryId.cs
- XmlObjectSerializerReadContextComplex.cs
- precedingquery.cs
- ContentType.cs
- NavigationEventArgs.cs
- BaseTemplateParser.cs
- ProfileSection.cs
- CultureInfoConverter.cs
- ValidateNames.cs
- TemplateApplicationHelper.cs
- UriTemplateVariablePathSegment.cs
- TaiwanLunisolarCalendar.cs
- SchemaInfo.cs
- AssociationSetEnd.cs
- AffineTransform3D.cs
- MouseEvent.cs
- MetadataCache.cs
- MobileCapabilities.cs
- SharedPerformanceCounter.cs
- XmlILAnnotation.cs
- MissingMemberException.cs
- SchemaReference.cs
- Math.cs
- FontUnit.cs
- X509Certificate2.cs
- dataobject.cs
- DateRangeEvent.cs
- TextProperties.cs
- WorkflowStateRollbackService.cs
- ModulesEntry.cs
- DrawTreeNodeEventArgs.cs
- XmlImplementation.cs
- DataGridColumn.cs
- SslSecurityTokenParameters.cs
- SqlTriggerContext.cs
- QueryOutputWriter.cs
- PropertySourceInfo.cs
- SafeSystemMetrics.cs
- MemberAssignment.cs
- DataRowIndexBuffer.cs
- StringValidatorAttribute.cs
- DataGridViewButtonCell.cs
- BrowserCapabilitiesCompiler.cs
- RangeValueProviderWrapper.cs
- FixedDocumentSequencePaginator.cs
- XmlValidatingReaderImpl.cs
- AuthenticationConfig.cs
- SqlUtils.cs
- XPathNodeIterator.cs
- ParseHttpDate.cs
- ZipIOExtraField.cs
- DocumentApplicationJournalEntry.cs
- EventWaitHandleSecurity.cs
- RolePrincipal.cs
- ListControlBoundActionList.cs
- EdmToObjectNamespaceMap.cs
- XmlParserContext.cs
- Site.cs
- DeploymentSection.cs
- InputManager.cs
- InputQueue.cs
- RootBrowserWindowAutomationPeer.cs
- WebSysDefaultValueAttribute.cs
- Pool.cs
- SingleStorage.cs
- StyleXamlParser.cs
- LocatorManager.cs
- EntityDataSourceDesignerHelper.cs
- BatchWriter.cs
- ZoomComboBox.cs
- PathFigureCollection.cs
- WebFaultClientMessageInspector.cs
- SecurityListenerSettingsLifetimeManager.cs
- AuthenticationModulesSection.cs
- metadatamappinghashervisitor.cs
- ForeignKeyConstraint.cs
- CodeIdentifiers.cs
- MemberRelationshipService.cs
- TypeBuilder.cs
- TextAnchor.cs
- UntrustedRecipientException.cs
- ChangeConflicts.cs
- ListViewItem.cs
- DbConnectionInternal.cs
- PtsHost.cs
- Command.cs
- ObfuscationAttribute.cs
- MenuItem.cs
- ComEventsHelper.cs