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
- Socket.cs
- PackageDigitalSignature.cs
- ExceptionCollection.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- DataMisalignedException.cs
- HwndTarget.cs
- MgmtConfigurationRecord.cs
- HuffmanTree.cs
- Missing.cs
- BufferedGenericXmlSecurityToken.cs
- Speller.cs
- MexBindingBindingCollectionElement.cs
- LinearGradientBrush.cs
- TypeResolver.cs
- UInt64.cs
- DataGridViewButtonColumn.cs
- PopOutPanel.cs
- FileRegion.cs
- XmlTypeMapping.cs
- TableLayoutRowStyleCollection.cs
- RecordsAffectedEventArgs.cs
- UserInitiatedNavigationPermission.cs
- Group.cs
- ListView.cs
- Rfc2898DeriveBytes.cs
- WorkerRequest.cs
- ServiceReference.cs
- FeatureSupport.cs
- ValidationSettings.cs
- CodeTypeReferenceExpression.cs
- EnumerableRowCollection.cs
- TimeIntervalCollection.cs
- AdjustableArrowCap.cs
- DoubleCollectionValueSerializer.cs
- CodeDomSerializerBase.cs
- HeaderUtility.cs
- BitmapDecoder.cs
- DeobfuscatingStream.cs
- EntityCollectionChangedParams.cs
- CodeGroup.cs
- MouseGestureValueSerializer.cs
- ClientRoleProvider.cs
- ViewStateModeByIdAttribute.cs
- CodePageUtils.cs
- BitmapDecoder.cs
- MediaPlayerState.cs
- ReliabilityContractAttribute.cs
- SystemIcons.cs
- StrokeFIndices.cs
- DotAtomReader.cs
- InfoCardRequestException.cs
- EncodingNLS.cs
- OdbcTransaction.cs
- Underline.cs
- ipaddressinformationcollection.cs
- GridViewUpdatedEventArgs.cs
- DocumentPage.cs
- StrokeDescriptor.cs
- DetailsViewRow.cs
- XamlClipboardData.cs
- CssClassPropertyAttribute.cs
- embossbitmapeffect.cs
- SvcMapFileSerializer.cs
- RemoteWebConfigurationHostStream.cs
- DataBindingExpressionBuilder.cs
- TreeNodeBinding.cs
- NullableConverter.cs
- SamlSubjectStatement.cs
- HMACSHA384.cs
- WindowCollection.cs
- FlowSwitchLink.cs
- RelationshipManager.cs
- RegistrationServices.cs
- TimeoutValidationAttribute.cs
- CodeExpressionRuleDeclaration.cs
- FunctionDetailsReader.cs
- DoubleAnimationBase.cs
- XsltException.cs
- ClientConfigurationSystem.cs
- BaseDataListPage.cs
- DirectoryObjectSecurity.cs
- MarkupExtensionParser.cs
- ParsedAttributeCollection.cs
- Annotation.cs
- FileIOPermission.cs
- ClusterSafeNativeMethods.cs
- TraceSwitch.cs
- AsyncOperation.cs
- SafeFileHandle.cs
- EventLogger.cs
- XPathArrayIterator.cs
- Currency.cs
- PopupRoot.cs
- Int32CAMarshaler.cs
- XslAst.cs
- GridViewSortEventArgs.cs
- DateTime.cs
- UnmanagedMemoryStream.cs
- basevalidator.cs
- RegularExpressionValidator.cs