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
- _NetRes.cs
- ShaderEffect.cs
- UICuesEvent.cs
- DefaultTraceListener.cs
- EventHandlersStore.cs
- TemplateControlBuildProvider.cs
- SoapElementAttribute.cs
- FormsAuthenticationEventArgs.cs
- Environment.cs
- InstancePersistenceEvent.cs
- SchemaInfo.cs
- SoapCommonClasses.cs
- InvokeProviderWrapper.cs
- DataControlFieldCell.cs
- QueryableFilterRepeater.cs
- Ref.cs
- SmiRequestExecutor.cs
- LockedHandleGlyph.cs
- EntityViewContainer.cs
- BuildResult.cs
- ScaleTransform.cs
- ObjectConverter.cs
- SrgsElementFactoryCompiler.cs
- RefExpr.cs
- CacheEntry.cs
- ResumeStoryboard.cs
- DateRangeEvent.cs
- EnumMember.cs
- PassportPrincipal.cs
- RuntimeCompatibilityAttribute.cs
- BaseComponentEditor.cs
- ArgumentOutOfRangeException.cs
- ProcessModuleDesigner.cs
- DecimalConverter.cs
- GroupBoxDesigner.cs
- AutomationIdentifier.cs
- ObjectContextServiceProvider.cs
- Encoding.cs
- EnglishPluralizationService.cs
- MailWebEventProvider.cs
- ToolStripItemCollection.cs
- DataServiceEntityAttribute.cs
- Metadata.cs
- TemplatePagerField.cs
- BamlTreeNode.cs
- Behavior.cs
- InstanceHandle.cs
- ErrorProvider.cs
- ClientClassGenerator.cs
- DataRowView.cs
- ProtocolsConfigurationEntry.cs
- SerializationInfoEnumerator.cs
- SmiEventSink_Default.cs
- AuthorizationSection.cs
- unsafeIndexingFilterStream.cs
- OpenFileDialog.cs
- XmlSchemaAttributeGroupRef.cs
- Deflater.cs
- FactoryGenerator.cs
- Attributes.cs
- DivideByZeroException.cs
- ACE.cs
- OdbcConnectionFactory.cs
- GPPOINT.cs
- CqlParserHelpers.cs
- Color.cs
- WebPartHeaderCloseVerb.cs
- NameObjectCollectionBase.cs
- LogicalExpressionTypeConverter.cs
- TemplateBindingExtensionConverter.cs
- ContractInferenceHelper.cs
- ValidatingReaderNodeData.cs
- newinstructionaction.cs
- FamilyTypeface.cs
- XmlBinaryReader.cs
- xdrvalidator.cs
- PrimitiveSchema.cs
- SchemaElementDecl.cs
- DataBoundControlHelper.cs
- OleDbDataReader.cs
- XmlWhitespace.cs
- PageEventArgs.cs
- LookupBindingPropertiesAttribute.cs
- RuntimeComponentFilter.cs
- DecoderBestFitFallback.cs
- DecoderFallbackWithFailureFlag.cs
- XmlDownloadManager.cs
- SqlProcedureAttribute.cs
- DecoderReplacementFallback.cs
- IisTraceWebEventProvider.cs
- dtdvalidator.cs
- ListViewGroupItemCollection.cs
- DataServiceResponse.cs
- DocumentEventArgs.cs
- Convert.cs
- RegexMatchCollection.cs
- SqlHelper.cs
- NameSpaceExtractor.cs
- RotationValidation.cs
- ObjectItemAssemblyLoader.cs