Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- SplashScreen.cs
- RolePrincipal.cs
- ExpressionWriter.cs
- SqlSelectStatement.cs
- COM2ExtendedBrowsingHandler.cs
- XsltContext.cs
- HtmlTableRow.cs
- SortFieldComparer.cs
- SafeReversePInvokeHandle.cs
- RelOps.cs
- MinMaxParagraphWidth.cs
- InternalRelationshipCollection.cs
- FileAuthorizationModule.cs
- KeyManager.cs
- ManipulationStartingEventArgs.cs
- StatusBarAutomationPeer.cs
- CorrelationManager.cs
- Suspend.cs
- SByteConverter.cs
- PartManifestEntry.cs
- DataGridViewRowsRemovedEventArgs.cs
- XslVisitor.cs
- IntSecurity.cs
- XPathParser.cs
- XmlSchemaAnnotated.cs
- WbemProvider.cs
- InsufficientExecutionStackException.cs
- TextTreeText.cs
- CodeCatchClauseCollection.cs
- EmptyStringExpandableObjectConverter.cs
- Hash.cs
- TextEditorMouse.cs
- StorageBasedPackageProperties.cs
- LongValidatorAttribute.cs
- SiteMapProvider.cs
- DataGridTextBox.cs
- TextBoxBase.cs
- WorkflowMessageEventHandler.cs
- ClientConfigPaths.cs
- Scheduling.cs
- SecurityDescriptor.cs
- GridViewDeletedEventArgs.cs
- Evaluator.cs
- ISFClipboardData.cs
- FrugalMap.cs
- PlainXmlSerializer.cs
- SqlConnectionStringBuilder.cs
- NumericUpDownAccelerationCollection.cs
- LinearKeyFrames.cs
- GlyphElement.cs
- NativeMethods.cs
- ArglessEventHandlerProxy.cs
- GifBitmapDecoder.cs
- DomainConstraint.cs
- CredentialManagerDialog.cs
- Quack.cs
- Compilation.cs
- CodeArrayIndexerExpression.cs
- SetterBase.cs
- BehaviorService.cs
- BamlLocalizableResource.cs
- Zone.cs
- BatchWriter.cs
- StringSource.cs
- SettingsPropertyIsReadOnlyException.cs
- Grammar.cs
- ObjectDataSourceView.cs
- AppSecurityManager.cs
- RegisteredArrayDeclaration.cs
- ArgumentException.cs
- DispatchWrapper.cs
- TranslateTransform.cs
- XPathDocumentNavigator.cs
- SqlDataSourceCache.cs
- WeakReadOnlyCollection.cs
- WebBrowserBase.cs
- InstanceHandleReference.cs
- WrappedDispatcherException.cs
- Attributes.cs
- ContractValidationHelper.cs
- WorkflowTimerService.cs
- ObjectDataSourceMethodEventArgs.cs
- OleDbRowUpdatingEvent.cs
- GregorianCalendarHelper.cs
- DbProviderServices.cs
- AspNetPartialTrustHelpers.cs
- InputScopeAttribute.cs
- InvalidPipelineStoreException.cs
- CodeIndexerExpression.cs
- ComEventsHelper.cs
- NotifyCollectionChangedEventArgs.cs
- Query.cs
- Rfc2898DeriveBytes.cs
- RawStylusInputCustomDataList.cs
- ReadOnlyDataSourceView.cs
- ProxyWebPartManager.cs
- UIElement3D.cs
- AuthenticationModuleElement.cs
- GcSettings.cs
- propertytag.cs