Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- WinFormsSpinner.cs
- CommonRemoteMemoryBlock.cs
- NumericUpDown.cs
- XmlDictionaryReader.cs
- ChannelServices.cs
- RSAOAEPKeyExchangeDeformatter.cs
- EntityModelBuildProvider.cs
- LeaseManager.cs
- XmlSerializerOperationBehavior.cs
- TypeElement.cs
- AsyncResult.cs
- XmlDomTextWriter.cs
- WebBrowserUriTypeConverter.cs
- securitycriticaldata.cs
- HostingEnvironmentWrapper.cs
- TaskExceptionHolder.cs
- SequenceDesignerAccessibleObject.cs
- ConnectionManagementElementCollection.cs
- Config.cs
- _StreamFramer.cs
- CodeDelegateInvokeExpression.cs
- TreeViewEvent.cs
- LiteralControl.cs
- AnonymousIdentificationSection.cs
- CommandEventArgs.cs
- AsymmetricKeyExchangeFormatter.cs
- DataGridToolTip.cs
- HtmlFormWrapper.cs
- HyperLink.cs
- NativeWindow.cs
- ToolStripPanelRenderEventArgs.cs
- TypeElementCollection.cs
- XPathNodeInfoAtom.cs
- XmlDocumentType.cs
- AdCreatedEventArgs.cs
- ActiveXHelper.cs
- HtmlElementCollection.cs
- Margins.cs
- StatusStrip.cs
- MarkupProperty.cs
- ResourceDisplayNameAttribute.cs
- TabControlCancelEvent.cs
- MsmqInputChannelListenerBase.cs
- SoapObjectWriter.cs
- WebServiceResponse.cs
- ReadOnlyKeyedCollection.cs
- AssemblyName.cs
- DrawingContextFlattener.cs
- ClientConfigPaths.cs
- SqlClientWrapperSmiStreamChars.cs
- SendKeys.cs
- base64Transforms.cs
- validationstate.cs
- Processor.cs
- FixedNode.cs
- dbdatarecord.cs
- UrlMapping.cs
- CompressEmulationStream.cs
- AuthenticationService.cs
- PointLight.cs
- GroupedContextMenuStrip.cs
- WindowsFont.cs
- CreatingCookieEventArgs.cs
- ConnectionManagementElementCollection.cs
- HMAC.cs
- ModifierKeysValueSerializer.cs
- Range.cs
- NumberSubstitution.cs
- StructuralObject.cs
- Operand.cs
- ProviderUtil.cs
- SafeRightsManagementSessionHandle.cs
- Model3D.cs
- ClientSettingsSection.cs
- PropertyTabChangedEvent.cs
- CuspData.cs
- HttpRequestCacheValidator.cs
- AspCompat.cs
- SQlBooleanStorage.cs
- X509ChainElement.cs
- HelpInfo.cs
- Array.cs
- SystemColors.cs
- SafeMILHandle.cs
- WebPartManagerInternals.cs
- AddInDeploymentState.cs
- XmlUtf8RawTextWriter.cs
- ParseChildrenAsPropertiesAttribute.cs
- WebServiceFault.cs
- UnknownBitmapEncoder.cs
- WebEvents.cs
- MethodAccessException.cs
- Point3DCollectionValueSerializer.cs
- EditorPart.cs
- XmlBinaryWriterSession.cs
- LayoutSettings.cs
- WindowsStatusBar.cs
- HttpMethodAttribute.cs
- TemplateComponentConnector.cs
- SmiMetaDataProperty.cs