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
- TypeUsageBuilder.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- _ProxyChain.cs
- PriorityItem.cs
- DateTimeSerializationSection.cs
- TransformProviderWrapper.cs
- XmlLangPropertyAttribute.cs
- XmlMembersMapping.cs
- InputBinding.cs
- SqlNotificationEventArgs.cs
- XsdDataContractImporter.cs
- XmlStringTable.cs
- EventEntry.cs
- EncryptedData.cs
- ReadWriteObjectLock.cs
- RoutingService.cs
- CodeChecksumPragma.cs
- ExpressionBuilder.cs
- EditBehavior.cs
- SrgsGrammar.cs
- HuffCodec.cs
- MappingMetadataHelper.cs
- Pointer.cs
- ThreadExceptionDialog.cs
- UInt64Storage.cs
- ClientSettings.cs
- HtmlSelect.cs
- RegistryExceptionHelper.cs
- SqlDataSourceSelectingEventArgs.cs
- ArraySortHelper.cs
- RecognizedWordUnit.cs
- TrackingMemoryStreamFactory.cs
- HttpCookie.cs
- StylusCollection.cs
- RestClientProxyHandler.cs
- SqlBulkCopy.cs
- JsonDeserializer.cs
- TextDecorations.cs
- ConfigurationLoader.cs
- ApplicationServicesHostFactory.cs
- WebCategoryAttribute.cs
- ColorTransformHelper.cs
- StaticFileHandler.cs
- X509CertificateTokenFactoryCredential.cs
- InternalConfigHost.cs
- SerializableTypeCodeDomSerializer.cs
- _CacheStreams.cs
- _DisconnectOverlappedAsyncResult.cs
- ParamArrayAttribute.cs
- SqlDataSourceQueryEditor.cs
- FileNameEditor.cs
- NamedPipeProcessProtocolHandler.cs
- sqlstateclientmanager.cs
- PersonalizationStateInfoCollection.cs
- SafeRightsManagementHandle.cs
- RotateTransform.cs
- Keywords.cs
- BrowserDefinitionCollection.cs
- DateTimeFormatInfoScanner.cs
- TypeSystem.cs
- PathGeometry.cs
- LayoutDump.cs
- ObjectListCommandsPage.cs
- arabicshape.cs
- SQLConvert.cs
- SecurityRuntime.cs
- ButtonChrome.cs
- SqlConnectionHelper.cs
- ErrorEventArgs.cs
- MenuItemStyleCollectionEditor.cs
- CodeGenerator.cs
- InkPresenter.cs
- _ListenerResponseStream.cs
- UIElement3D.cs
- ToolStripContentPanelRenderEventArgs.cs
- XslTransform.cs
- QueryTaskGroupState.cs
- SequentialActivityDesigner.cs
- Parsers.cs
- BitmapEffectInput.cs
- FileChangeNotifier.cs
- ModifiableIteratorCollection.cs
- ClickablePoint.cs
- _SslStream.cs
- DetailsViewRowCollection.cs
- PersonalizablePropertyEntry.cs
- XhtmlConformanceSection.cs
- CompileLiteralTextParser.cs
- SerializationStore.cs
- SqlTypesSchemaImporter.cs
- RegexRunnerFactory.cs
- CodeDomSerializerBase.cs
- XmlSerializerVersionAttribute.cs
- Expression.cs
- QilTargetType.cs
- OleDbConnectionFactory.cs
- AlphaSortedEnumConverter.cs
- Stackframe.cs
- TextElementEnumerator.cs
- HttpChannelListener.cs