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
- TypeHelper.cs
- EffectiveValueEntry.cs
- EdmType.cs
- IndependentAnimationStorage.cs
- documentsequencetextcontainer.cs
- EngineSite.cs
- BitmapEffectState.cs
- TextElement.cs
- DocumentPageTextView.cs
- PartitionResolver.cs
- DataColumnSelectionConverter.cs
- DependsOnAttribute.cs
- SQLInt32Storage.cs
- ProjectedSlot.cs
- TdsValueSetter.cs
- FilterRepeater.cs
- SuppressIldasmAttribute.cs
- X509ChainElement.cs
- NominalTypeEliminator.cs
- ToolStripPanelRenderEventArgs.cs
- TaskFormBase.cs
- ImageConverter.cs
- IconConverter.cs
- MenuEventArgs.cs
- ExtenderProvidedPropertyAttribute.cs
- WebPartCancelEventArgs.cs
- TaskDesigner.cs
- SoapHeaderException.cs
- MessageDecoder.cs
- FocusTracker.cs
- TreePrinter.cs
- ContentValidator.cs
- SoapHeaders.cs
- remotingproxy.cs
- DockPanel.cs
- SafeRightsManagementQueryHandle.cs
- ListViewEditEventArgs.cs
- JoinSymbol.cs
- WindowsFormsEditorServiceHelper.cs
- Button.cs
- Int64KeyFrameCollection.cs
- OleDbInfoMessageEvent.cs
- FutureFactory.cs
- XamlReader.cs
- XmlILConstructAnalyzer.cs
- VerificationException.cs
- ComponentResourceManager.cs
- CompiledRegexRunnerFactory.cs
- TextTreeExtractElementUndoUnit.cs
- EventLogPropertySelector.cs
- TextSelection.cs
- MouseGestureValueSerializer.cs
- StandardCommands.cs
- AuthorizationSection.cs
- SafeEventLogWriteHandle.cs
- RoleManagerModule.cs
- WeakReference.cs
- BinaryWriter.cs
- DbProviderFactories.cs
- CodeDomExtensionMethods.cs
- StrokeNodeData.cs
- MailFileEditor.cs
- ConfigurationManagerHelperFactory.cs
- XmlSchemaNotation.cs
- URI.cs
- VisualStyleInformation.cs
- XmlWrappingReader.cs
- KeyConverter.cs
- XmlQueryOutput.cs
- XmlDocument.cs
- ChineseLunisolarCalendar.cs
- FileSystemEventArgs.cs
- EnumMemberAttribute.cs
- StreamGeometry.cs
- OleDbConnection.cs
- TextParentUndoUnit.cs
- PropertyConverter.cs
- DebuggerAttributes.cs
- TcpTransportSecurityElement.cs
- PublisherMembershipCondition.cs
- DictionaryEntry.cs
- HostUtils.cs
- controlskin.cs
- XappLauncher.cs
- ObservableDictionary.cs
- HtmlImage.cs
- VectorAnimationUsingKeyFrames.cs
- SoapAttributeOverrides.cs
- Point3D.cs
- TypeUsageBuilder.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- Util.cs
- HttpCachePolicyWrapper.cs
- ClearTypeHintValidation.cs
- baseaxisquery.cs
- Message.cs
- ErrorFormatterPage.cs
- IntegerValidatorAttribute.cs
- AncestorChangedEventArgs.cs
- TargetPerspective.cs