Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- AxImporter.cs
- ByteArrayHelperWithString.cs
- UnknownWrapper.cs
- DictionarySectionHandler.cs
- Vector3DValueSerializer.cs
- EventLogQuery.cs
- EnterpriseServicesHelper.cs
- XsdBuilder.cs
- StrokeCollectionDefaultValueFactory.cs
- CodeSpit.cs
- SmiEventStream.cs
- ObjectContext.cs
- MLangCodePageEncoding.cs
- PersianCalendar.cs
- MgmtConfigurationRecord.cs
- SmtpMail.cs
- KeyboardEventArgs.cs
- ColorMap.cs
- FixedTextPointer.cs
- DBConcurrencyException.cs
- returneventsaver.cs
- OrderedDictionary.cs
- BlurBitmapEffect.cs
- ConfigurationManagerHelper.cs
- AutoSizeComboBox.cs
- ServiceHostingEnvironment.cs
- TaiwanLunisolarCalendar.cs
- StateItem.cs
- WebPartEditorApplyVerb.cs
- Cursors.cs
- SqlConnectionString.cs
- CompositeCollectionView.cs
- EventlogProvider.cs
- AutoResizedEvent.cs
- ForeignKeyConstraint.cs
- EntityReference.cs
- DateRangeEvent.cs
- MediaElementAutomationPeer.cs
- FrameworkReadOnlyPropertyMetadata.cs
- TextParentUndoUnit.cs
- MultiTouchSystemGestureLogic.cs
- Point3DConverter.cs
- templategroup.cs
- DataListCommandEventArgs.cs
- QueryRewriter.cs
- _HTTPDateParse.cs
- PatternMatcher.cs
- DataGridColumnHeader.cs
- _UriSyntax.cs
- KeyValuePairs.cs
- Expander.cs
- ListSourceHelper.cs
- CanonicalFormWriter.cs
- ConnectionProviderAttribute.cs
- RectangleConverter.cs
- WebHeaderCollection.cs
- LineUtil.cs
- TypeBuilder.cs
- InputQueueChannel.cs
- DataSourceSelectArguments.cs
- WebServiceErrorEvent.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- XmlResolver.cs
- PrinterUnitConvert.cs
- ResizeBehavior.cs
- ParameterBinding.cs
- DeviceSpecificDialogCachedState.cs
- EnumMemberAttribute.cs
- XmlFileEditor.cs
- TransactionManager.cs
- XdrBuilder.cs
- WebRequestModuleElement.cs
- OutputWindow.cs
- SqlDataSourceSelectingEventArgs.cs
- BitmapInitialize.cs
- GridViewDeletedEventArgs.cs
- TextAutomationPeer.cs
- XmlSchemaProviderAttribute.cs
- RegexBoyerMoore.cs
- login.cs
- ColorConverter.cs
- CompositeCollection.cs
- BitmapPalettes.cs
- TaskExceptionHolder.cs
- TimelineClockCollection.cs
- RangeEnumerable.cs
- PerspectiveCamera.cs
- InvalidFilterCriteriaException.cs
- SelectedGridItemChangedEvent.cs
- ReferenceAssemblyAttribute.cs
- CodePageUtils.cs
- ReceiveReply.cs
- DrawingContextDrawingContextWalker.cs
- ErrorRuntimeConfig.cs
- Registration.cs
- ConfigUtil.cs
- PopupRoot.cs
- StreamSecurityUpgradeInitiator.cs
- PageHandlerFactory.cs
- CellLabel.cs