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
- SmiRequestExecutor.cs
- dataprotectionpermissionattribute.cs
- Exception.cs
- DataGridRowHeader.cs
- DecimalAverageAggregationOperator.cs
- PropertySourceInfo.cs
- ListControlDesigner.cs
- DataGridRelationshipRow.cs
- BamlCollectionHolder.cs
- UriTemplateVariablePathSegment.cs
- DesigntimeLicenseContext.cs
- Canvas.cs
- RoutedEventValueSerializer.cs
- ThumbButtonInfo.cs
- CrossAppDomainChannel.cs
- XmlSchemas.cs
- TreeNodeStyle.cs
- DesignerTransactionCloseEvent.cs
- DecoderFallbackWithFailureFlag.cs
- FileLogRecord.cs
- AsyncPostBackErrorEventArgs.cs
- XmlWhitespace.cs
- EtwTrace.cs
- MsmqUri.cs
- XmlSyndicationContent.cs
- AnimatedTypeHelpers.cs
- SiteOfOriginContainer.cs
- _LoggingObject.cs
- OledbConnectionStringbuilder.cs
- CallTemplateAction.cs
- ProviderUtil.cs
- SqlClientWrapperSmiStream.cs
- Style.cs
- WebPartEditorCancelVerb.cs
- translator.cs
- EntitySetDataBindingList.cs
- Localizer.cs
- AssemblyResourceLoader.cs
- Rect3DConverter.cs
- DrawTreeNodeEventArgs.cs
- PenLineCapValidation.cs
- indexingfiltermarshaler.cs
- ActivityMarkupSerializationProvider.cs
- QilFactory.cs
- ButtonChrome.cs
- EditorPartCollection.cs
- InlineUIContainer.cs
- ParseHttpDate.cs
- WebPartVerbsEventArgs.cs
- CommentEmitter.cs
- AspProxy.cs
- Attribute.cs
- BlurBitmapEffect.cs
- DecimalFormatter.cs
- Rect3D.cs
- XmlSchemaAttributeGroupRef.cs
- IntSecurity.cs
- WebPartsSection.cs
- ConversionValidationRule.cs
- BindToObject.cs
- CheckBoxBaseAdapter.cs
- DataTransferEventArgs.cs
- Int64Animation.cs
- PolyLineSegment.cs
- PropertyValueUIItem.cs
- MimeParameter.cs
- ArglessEventHandlerProxy.cs
- WindowExtensionMethods.cs
- DesignerTextWriter.cs
- WriteTimeStream.cs
- ClientSideQueueItem.cs
- NetSectionGroup.cs
- FlowchartStart.xaml.cs
- PassportAuthenticationEventArgs.cs
- DateTimeOffset.cs
- DefaultTextStore.cs
- NullableFloatMinMaxAggregationOperator.cs
- ManageRequest.cs
- StringStorage.cs
- WinFormsSecurity.cs
- TextParagraphView.cs
- TimeSpanConverter.cs
- RawAppCommandInputReport.cs
- StrokeCollectionConverter.cs
- XmlDataContract.cs
- Triplet.cs
- Task.cs
- Parsers.cs
- ContextMenu.cs
- DbConnectionPoolGroupProviderInfo.cs
- DataColumnMapping.cs
- DesignerCategoryAttribute.cs
- ToolBarPanel.cs
- Missing.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ControlUtil.cs
- ScriptServiceAttribute.cs
- RemotingConfiguration.cs
- GeometryHitTestParameters.cs
- DeploymentSection.cs