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
- DataServiceQueryProvider.cs
- PropertyChangingEventArgs.cs
- TreeNodeStyleCollection.cs
- CommandExpr.cs
- RequestValidator.cs
- DbConnectionPoolGroup.cs
- AddInActivator.cs
- TextStore.cs
- ExpressionLexer.cs
- DbParameterCollection.cs
- OrElse.cs
- RowUpdatedEventArgs.cs
- XmlSchemaNotation.cs
- TypeNameConverter.cs
- XPathAncestorQuery.cs
- ModuleBuilderData.cs
- Baml2006ReaderSettings.cs
- RefreshEventArgs.cs
- CommandPlan.cs
- LineUtil.cs
- XmlSchemaException.cs
- ValueTypeFixupInfo.cs
- WebPartCancelEventArgs.cs
- Vector3dCollection.cs
- ErrorTableItemStyle.cs
- CancelAsyncOperationRequest.cs
- UrlPath.cs
- ParameterBinding.cs
- ScalarType.cs
- CreateUserErrorEventArgs.cs
- CustomPopupPlacement.cs
- XmlDocumentFragment.cs
- SlipBehavior.cs
- FlowDocumentFormatter.cs
- TerminateDesigner.cs
- TableLayoutCellPaintEventArgs.cs
- BaseProcessor.cs
- PersonalizationProviderCollection.cs
- CacheVirtualItemsEvent.cs
- RedirectionProxy.cs
- XmlWhitespace.cs
- Message.cs
- AccessibilityHelperForXpWin2k3.cs
- XomlCompilerHelpers.cs
- ComponentResourceKeyConverter.cs
- SelectionRangeConverter.cs
- JavaScriptObjectDeserializer.cs
- SafeTokenHandle.cs
- RemoteWebConfigurationHost.cs
- ContextMenuService.cs
- SaveFileDialog.cs
- MetaChildrenColumn.cs
- XmlValidatingReaderImpl.cs
- HttpCachePolicyWrapper.cs
- FileRecordSequenceHelper.cs
- ColumnCollection.cs
- EnumUnknown.cs
- ISFClipboardData.cs
- EdmItemError.cs
- GridViewCancelEditEventArgs.cs
- StringFunctions.cs
- Thickness.cs
- DefaultBinder.cs
- PropertyDescriptorComparer.cs
- CutCopyPasteHelper.cs
- ConfigurationProperty.cs
- XmlProcessingInstruction.cs
- ScrollItemProviderWrapper.cs
- Handle.cs
- TextRangeEditTables.cs
- DefaultSection.cs
- TreeView.cs
- ActivityExecutorDelegateInfo.cs
- ValidationRule.cs
- XmlObjectSerializerContext.cs
- MissingMethodException.cs
- JapaneseLunisolarCalendar.cs
- ObjectListCommandEventArgs.cs
- _NestedMultipleAsyncResult.cs
- ArithmeticException.cs
- OrthographicCamera.cs
- RootDesignerSerializerAttribute.cs
- DataGridViewCellStyle.cs
- HtmlGenericControl.cs
- NullableDecimalAverageAggregationOperator.cs
- SequenceDesignerAccessibleObject.cs
- InputScope.cs
- DataGridViewCellConverter.cs
- DrawingCollection.cs
- WorkflowView.cs
- CodeValidator.cs
- XmlLangPropertyAttribute.cs
- RedistVersionInfo.cs
- RestHandlerFactory.cs
- SqlDataSourceEnumerator.cs
- Int64AnimationBase.cs
- UserControl.cs
- Renderer.cs
- BamlRecordWriter.cs
- InheritanceService.cs