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
- TrackingMemoryStreamFactory.cs
- ResourceAssociationTypeEnd.cs
- DecoderBestFitFallback.cs
- PropertyGeneratedEventArgs.cs
- AdjustableArrowCap.cs
- WebPartConnectionCollection.cs
- PkcsMisc.cs
- TableItemStyle.cs
- UnmanagedBitmapWrapper.cs
- SoapReflectionImporter.cs
- CodeCompileUnit.cs
- ControlBuilder.cs
- XmlEntity.cs
- StringPropertyBuilder.cs
- OleCmdHelper.cs
- FontDriver.cs
- PropertyRef.cs
- FunctionImportElement.cs
- EntityTypeBase.cs
- MatrixCamera.cs
- SHA256Managed.cs
- mediaeventargs.cs
- CuspData.cs
- TypeEnumerableViewSchema.cs
- SSmlParser.cs
- SqlLiftIndependentRowExpressions.cs
- DCSafeHandle.cs
- AssertFilter.cs
- SystemIcmpV4Statistics.cs
- RuleRef.cs
- TemplateXamlParser.cs
- HMACMD5.cs
- SimpleColumnProvider.cs
- __FastResourceComparer.cs
- WorkflowValidationFailedException.cs
- BaseTemplatedMobileComponentEditor.cs
- MsmqDecodeHelper.cs
- UnicodeEncoding.cs
- ValidationEventArgs.cs
- WebPartConnectionsCancelVerb.cs
- DesigntimeLicenseContext.cs
- DataServiceCollectionOfT.cs
- StringBuilder.cs
- ScalarOps.cs
- PenThreadWorker.cs
- SqlInternalConnectionSmi.cs
- COM2ColorConverter.cs
- GlyphInfoList.cs
- GridItem.cs
- IdentityNotMappedException.cs
- SafeRightsManagementHandle.cs
- UnitySerializationHolder.cs
- MultiPropertyDescriptorGridEntry.cs
- GroupBoxRenderer.cs
- ConnectionManager.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- SignatureToken.cs
- DataSpaceManager.cs
- SerializeAbsoluteContext.cs
- InsufficientExecutionStackException.cs
- RootDesignerSerializerAttribute.cs
- ProjectionPlan.cs
- CompoundFileStreamReference.cs
- PolyBezierSegment.cs
- VisualStyleElement.cs
- DateTimePicker.cs
- PolicyManager.cs
- _HeaderInfoTable.cs
- CodeTypeReferenceExpression.cs
- WindowsToolbar.cs
- IDReferencePropertyAttribute.cs
- DocumentViewerBaseAutomationPeer.cs
- TdsParserStaticMethods.cs
- AsyncContentLoadedEventArgs.cs
- JsonWriter.cs
- SqlBuilder.cs
- HelpProvider.cs
- EntityDataSourceContainerNameConverter.cs
- CompModSwitches.cs
- ToolBarButtonDesigner.cs
- CharUnicodeInfo.cs
- VariableDesigner.xaml.cs
- UTF32Encoding.cs
- ListManagerBindingsCollection.cs
- XmlSerializationWriter.cs
- StringConcat.cs
- CompiledRegexRunner.cs
- FileLevelControlBuilderAttribute.cs
- Semaphore.cs
- MetafileHeaderEmf.cs
- HwndPanningFeedback.cs
- TextEditorTyping.cs
- EmptyControlCollection.cs
- InternalConfigEventArgs.cs
- ArgIterator.cs
- BoundColumn.cs
- PeerNameRecordCollection.cs
- GridViewUpdatedEventArgs.cs
- HttpProfileGroupBase.cs
- SimpleFileLog.cs