Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- Assert.cs
- TimeoutValidationAttribute.cs
- DataGridSortCommandEventArgs.cs
- CompositionTarget.cs
- XmlSchemaSubstitutionGroup.cs
- TextRangeProviderWrapper.cs
- KoreanCalendar.cs
- ToolStripManager.cs
- RegexInterpreter.cs
- RenderData.cs
- ColumnResizeAdorner.cs
- StorageComplexTypeMapping.cs
- PrimitiveXmlSerializers.cs
- EpmSyndicationContentDeSerializer.cs
- InvokePattern.cs
- LayoutTable.cs
- XmlTextReaderImplHelpers.cs
- EventQueueState.cs
- _LazyAsyncResult.cs
- ListBox.cs
- ValidationEventArgs.cs
- BinaryEditor.cs
- ComponentRenameEvent.cs
- HttpServerUtilityWrapper.cs
- Knowncolors.cs
- EnumBuilder.cs
- BinaryFormatterWriter.cs
- LiteralTextContainerControlBuilder.cs
- ProcessModelInfo.cs
- VolatileEnlistmentMultiplexing.cs
- xdrvalidator.cs
- FixedSOMImage.cs
- TriggerActionCollection.cs
- ProxyHwnd.cs
- WindowsSysHeader.cs
- NetworkAddressChange.cs
- NetworkInformationException.cs
- WebPartDisplayModeEventArgs.cs
- ServiceChannel.cs
- ToolStripStatusLabel.cs
- SymbolType.cs
- DateTimePicker.cs
- HttpStreamFormatter.cs
- OutputCacheModule.cs
- StateItem.cs
- CustomPopupPlacement.cs
- ThreadPoolTaskScheduler.cs
- TypeGeneratedEventArgs.cs
- BinaryConverter.cs
- XslNumber.cs
- WebPartDescription.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- SqlSelectClauseBuilder.cs
- NativeMethods.cs
- ActivityTypeResolver.xaml.cs
- XhtmlTextWriter.cs
- HtmlInputPassword.cs
- DropDownButton.cs
- ThemeDirectoryCompiler.cs
- EncoderExceptionFallback.cs
- SpellerInterop.cs
- CodeArrayCreateExpression.cs
- EmptyEnumerator.cs
- COAUTHINFO.cs
- ToolStripTextBox.cs
- BindingBase.cs
- SimpleNameService.cs
- RowType.cs
- DragDrop.cs
- TransformProviderWrapper.cs
- DataTableMappingCollection.cs
- UnicodeEncoding.cs
- TypeBrowser.xaml.cs
- Image.cs
- EventDescriptorCollection.cs
- FixedSchema.cs
- CompletionBookmark.cs
- RuntimeArgumentHandle.cs
- CssClassPropertyAttribute.cs
- SizeIndependentAnimationStorage.cs
- XPathMultyIterator.cs
- BmpBitmapEncoder.cs
- InvalidateEvent.cs
- DecimalMinMaxAggregationOperator.cs
- Int32CAMarshaler.cs
- BamlCollectionHolder.cs
- ObjectMemberMapping.cs
- Roles.cs
- Rect.cs
- SelectionPatternIdentifiers.cs
- Geometry.cs
- DataServiceContext.cs
- StylusShape.cs
- SqlCacheDependencyDatabase.cs
- MetadataException.cs
- BufferBuilder.cs
- TemplateInstanceAttribute.cs
- SymbolType.cs
- EntityDesignerDataSourceView.cs
- HandlerFactoryCache.cs