Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Windows / DependencyPropertyValueSerializer.cs / 1305600 / 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
- DataGridViewLinkColumn.cs
- TextRangeAdaptor.cs
- FileDialogCustomPlace.cs
- CrossSiteScriptingValidation.cs
- ColorConvertedBitmap.cs
- DesignerProperties.cs
- Menu.cs
- UrlMapping.cs
- WSHttpSecurity.cs
- IERequestCache.cs
- DataGridViewSortCompareEventArgs.cs
- ImageSource.cs
- SafeNativeMethodsCLR.cs
- ExpressionVisitor.cs
- DataObjectCopyingEventArgs.cs
- IfAction.cs
- DataListItem.cs
- TabControlEvent.cs
- IDReferencePropertyAttribute.cs
- ObjectReaderCompiler.cs
- XmlAnyElementAttribute.cs
- EncodingFallbackAwareXmlTextWriter.cs
- ObjectDataSourceMethodEventArgs.cs
- BrushConverter.cs
- EncoderFallback.cs
- FigureParagraph.cs
- WorkflowApplicationUnloadedException.cs
- DataGridViewBindingCompleteEventArgs.cs
- webproxy.cs
- Icon.cs
- TraceSource.cs
- HwndProxyElementProvider.cs
- DataListItemEventArgs.cs
- PropertyItemInternal.cs
- ColorIndependentAnimationStorage.cs
- ProcessHostMapPath.cs
- SQLInt16.cs
- FixedPageProcessor.cs
- _NetworkingPerfCounters.cs
- RequestQueryParser.cs
- FontCollection.cs
- DrawingAttributesDefaultValueFactory.cs
- ToolStripItemRenderEventArgs.cs
- sqlnorm.cs
- TreeViewAutomationPeer.cs
- ListViewCommandEventArgs.cs
- SqlInternalConnectionSmi.cs
- Comparer.cs
- SafeWaitHandle.cs
- UidPropertyAttribute.cs
- FileLevelControlBuilderAttribute.cs
- PageThemeCodeDomTreeGenerator.cs
- XmlQualifiedNameTest.cs
- FixUp.cs
- StringReader.cs
- ChannelManagerHelpers.cs
- VerificationException.cs
- StrokeDescriptor.cs
- HostedTransportConfigurationManager.cs
- UriScheme.cs
- WindowsToolbar.cs
- MatchAllMessageFilter.cs
- XamlSerializationHelper.cs
- ReverseComparer.cs
- EllipticalNodeOperations.cs
- SafeNativeMethods.cs
- SystemIPInterfaceStatistics.cs
- FileDialog_Vista_Interop.cs
- DataSourceXmlSubItemAttribute.cs
- ExpandSegmentCollection.cs
- TrustManagerPromptUI.cs
- GeometryValueSerializer.cs
- DataGridViewEditingControlShowingEventArgs.cs
- TraceContextRecord.cs
- HtmlFormParameterReader.cs
- MemberDescriptor.cs
- TriState.cs
- RuleInfoComparer.cs
- WebConfigurationFileMap.cs
- ReaderContextStackData.cs
- ExtenderProviderService.cs
- GenerateTemporaryTargetAssembly.cs
- ActiveDesignSurfaceEvent.cs
- XmlCharType.cs
- DynamicRenderer.cs
- RangeValuePattern.cs
- Queue.cs
- SQLSingle.cs
- assemblycache.cs
- DataSet.cs
- DecoderReplacementFallback.cs
- AssociationTypeEmitter.cs
- QilXmlWriter.cs
- ReadWriteSpinLock.cs
- Unit.cs
- TextEditorLists.cs
- ArraySubsetEnumerator.cs
- SqlInternalConnectionSmi.cs
- EnumerableCollectionView.cs
- FacetDescriptionElement.cs