Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / System / Windows / DependencyPropertyValueSerializer.cs / 1 / DependencyPropertyValueSerializer.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: CommandValueSerializer.cs // // Contents: ValueSerializer for DependencyProperty // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Windows.Markup; namespace System.Windows { internal class DependencyPropertyValueSerializer : ValueSerializer { public override bool CanConvertToString(object value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override string ConvertToString(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { return typeSerializer.ConvertToString(property.OwnerType, context) + "." + property.Name; } } throw GetConvertToException(value, typeof(string)); } public override IEnumerableTypeReferences(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { return new Type[] { property.OwnerType }; } else { return base.TypeReferences(value, context); } } public override object ConvertFromString(string value, IValueSerializerContext context) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { int dotIndex = value.IndexOf('.'); if (dotIndex >= 0) { string typeName = value.Substring(0, dotIndex - 1); Type ownerType = typeSerializer.ConvertFromString(typeName, context) as Type; if (ownerType != null) { return DependencyProperty.FromName(typeName, ownerType); } } } throw GetConvertFromException(value); } } } // 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: CommandValueSerializer.cs // // Contents: ValueSerializer for DependencyProperty // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Windows.Markup; namespace System.Windows { internal class DependencyPropertyValueSerializer : ValueSerializer { public override bool CanConvertToString(object value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override string ConvertToString(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { return typeSerializer.ConvertToString(property.OwnerType, context) + "." + property.Name; } } throw GetConvertToException(value, typeof(string)); } public override IEnumerable TypeReferences(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { return new Type[] { property.OwnerType }; } else { return base.TypeReferences(value, context); } } public override object ConvertFromString(string value, IValueSerializerContext context) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { int dotIndex = value.IndexOf('.'); if (dotIndex >= 0) { string typeName = value.Substring(0, dotIndex - 1); Type ownerType = typeSerializer.ConvertFromString(typeName, context) as Type; if (ownerType != null) { return DependencyProperty.FromName(typeName, ownerType); } } } throw GetConvertFromException(value); } } } // 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
- ToolStripSeparator.cs
- UserControl.cs
- TemplateControl.cs
- DesignerSerializationOptionsAttribute.cs
- CqlQuery.cs
- ReaderOutput.cs
- X509CertificateClaimSet.cs
- XmlDocumentSerializer.cs
- ExpressionBinding.cs
- XmlLanguage.cs
- TextDecorationCollectionConverter.cs
- ClientTargetSection.cs
- StackBuilderSink.cs
- DisplayMemberTemplateSelector.cs
- OptimizedTemplateContent.cs
- DnsPermission.cs
- IndexOutOfRangeException.cs
- TreeBuilderXamlTranslator.cs
- WebPartManager.cs
- SqlCommandAsyncResult.cs
- DbCommandDefinition.cs
- DecimalFormatter.cs
- BuildProvider.cs
- EmptyImpersonationContext.cs
- ThemeableAttribute.cs
- WindowsButton.cs
- BordersPage.cs
- updatecommandorderer.cs
- Transaction.cs
- DataGridViewCellParsingEventArgs.cs
- SafeRegistryHandle.cs
- TypeCacheManager.cs
- TraceLevelHelper.cs
- ClusterRegistryConfigurationProvider.cs
- DataGridViewRowEventArgs.cs
- CodeDomConfigurationHandler.cs
- MdiWindowListStrip.cs
- TrackingMemoryStreamFactory.cs
- EUCJPEncoding.cs
- TextInfo.cs
- TextBreakpoint.cs
- OdbcConnectionFactory.cs
- ForEachAction.cs
- CallbackValidator.cs
- HitTestResult.cs
- FixedTextSelectionProcessor.cs
- ReflectEventDescriptor.cs
- RoleService.cs
- DocumentPageHost.cs
- TdsEnums.cs
- ExtractorMetadata.cs
- ApplicationManager.cs
- ExtractorMetadata.cs
- EncoderNLS.cs
- RC2.cs
- Rectangle.cs
- HitTestParameters.cs
- UserControl.cs
- DataGridColumnReorderingEventArgs.cs
- MetafileHeaderWmf.cs
- TripleDES.cs
- TextFormatterContext.cs
- GraphicsContext.cs
- ConditionalAttribute.cs
- ZipIOExtraFieldZip64Element.cs
- Dispatcher.cs
- EntityDataSourceMemberPath.cs
- WebEvents.cs
- NativeMethods.cs
- ConstraintStruct.cs
- SessionIDManager.cs
- Int32RectValueSerializer.cs
- AssemblyLoader.cs
- EntityDataSourceValidationException.cs
- SettingsPropertyValueCollection.cs
- SchemaSetCompiler.cs
- WebPartDescriptionCollection.cs
- CalendarAutomationPeer.cs
- PreProcessInputEventArgs.cs
- LassoSelectionBehavior.cs
- EventPrivateKey.cs
- CellRelation.cs
- WebBrowserHelper.cs
- PaperSize.cs
- MsmqActivation.cs
- _ChunkParse.cs
- EmptyControlCollection.cs
- CatalogZoneBase.cs
- FontFaceLayoutInfo.cs
- EmptyEnumerator.cs
- LicenseContext.cs
- CodeExpressionRuleDeclaration.cs
- ConfigurationErrorsException.cs
- DataGridViewColumnStateChangedEventArgs.cs
- ListMarkerLine.cs
- WebSysDescriptionAttribute.cs
- SmiContextFactory.cs
- cookiecontainer.cs
- CommandHelpers.cs
- ConnectionAcceptor.cs