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
- PerfProviderCollection.cs
- TransformerTypeCollection.cs
- CharAnimationBase.cs
- GenericTextProperties.cs
- WsdlImporter.cs
- Trace.cs
- RelatedEnd.cs
- VersionValidator.cs
- CompositeDataBoundControl.cs
- ExtendedPropertyCollection.cs
- TemplateLookupAction.cs
- XmlLanguageConverter.cs
- _HTTPDateParse.cs
- BindingMemberInfo.cs
- XpsS0ValidatingLoader.cs
- UnsafeNativeMethods.cs
- LinkConverter.cs
- MD5CryptoServiceProvider.cs
- CachingHintValidation.cs
- XPathItem.cs
- SamlAttribute.cs
- PathGradientBrush.cs
- FileLoadException.cs
- DataObjectCopyingEventArgs.cs
- DockProviderWrapper.cs
- ProcessModule.cs
- SerializableAttribute.cs
- RepeaterCommandEventArgs.cs
- AppliedDeviceFiltersEditor.cs
- TogglePattern.cs
- HtmlMeta.cs
- InstanceKeyView.cs
- IBuiltInEvidence.cs
- ReflectionUtil.cs
- XmlConvert.cs
- AnimationClock.cs
- FixedHyperLink.cs
- FixedSOMTableRow.cs
- ListBindingConverter.cs
- EmptyImpersonationContext.cs
- HostingEnvironmentException.cs
- UpdatePanelControlTrigger.cs
- CompilerCollection.cs
- RegexWorker.cs
- StructuredCompositeActivityDesigner.cs
- FacetChecker.cs
- WinEventWrap.cs
- TreeNodeBinding.cs
- TypeLibraryHelper.cs
- TreeChangeInfo.cs
- Regex.cs
- CompiledQueryCacheKey.cs
- PropertyMappingExceptionEventArgs.cs
- oledbmetadatacollectionnames.cs
- WebPageTraceListener.cs
- AndCondition.cs
- MissingMemberException.cs
- HostProtectionPermission.cs
- UriTemplateTableMatchCandidate.cs
- ItemChangedEventArgs.cs
- Typeface.cs
- securestring.cs
- SamlAction.cs
- InstanceCreationEditor.cs
- NamedPipeChannelFactory.cs
- ClientFormsIdentity.cs
- AdapterUtil.cs
- DataGridSortCommandEventArgs.cs
- ProcessProtocolHandler.cs
- DataColumnPropertyDescriptor.cs
- ListSourceHelper.cs
- JsonUriDataContract.cs
- StorageComplexTypeMapping.cs
- BamlBinaryReader.cs
- SqlDataSourceFilteringEventArgs.cs
- LicenseProviderAttribute.cs
- ObjectDataSourceView.cs
- StandardOleMarshalObject.cs
- PageCatalogPartDesigner.cs
- RtfControls.cs
- HttpPostedFile.cs
- DesignerSerializationManager.cs
- ReadContentAsBinaryHelper.cs
- CounterCreationData.cs
- DbConnectionPoolCounters.cs
- DSASignatureDeformatter.cs
- ChtmlSelectionListAdapter.cs
- ImplicitInputBrush.cs
- LicenseProviderAttribute.cs
- ExtensionDataObject.cs
- SettingsAttributeDictionary.cs
- ComponentResourceKeyConverter.cs
- SelectedDatesCollection.cs
- LookupNode.cs
- LogRecordSequence.cs
- SymbolPair.cs
- XmlSchemaIdentityConstraint.cs
- DirectoryNotFoundException.cs
- GridErrorDlg.cs
- OuterGlowBitmapEffect.cs