StringValueSerializer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Base / MS / Internal / Markup / StringValueSerializer.cs / 1 / StringValueSerializer.cs

                            //------------------------------------------------------------------------ 
//
//  Microsoft Windows Client Platform
//  Copyright (C) Microsoft Corporation, 2005
// 
//  File:      StringValueSerializer.cs
// 
//  Contents:  Stub value serializer for strings 
//
//  Created:   04/28/2005 [....] 
//
//-----------------------------------------------------------------------

using System.Windows.Markup; 

namespace MS.Internal.Serialization 
{ 
    /// 
    /// Stub string serializer. It exists to remove special caseing strings in a couple cases in the 
    /// serialization code. It essentially states that strings are serialized as their value.
    /// 
    internal sealed class StringValueSerializer : ValueSerializer
    { 
        public StringValueSerializer() { }
 
        public override bool CanConvertToString(object value, IValueSerializerContext context) 
        {
            return true; 
        }

        public override bool CanConvertFromString(string value, IValueSerializerContext context)
        { 
            return true;
        } 
 
        public override object ConvertFromString(string value, IValueSerializerContext context)
        { 
            return value;
        }

        public override string ConvertToString(object value, IValueSerializerContext context) 
        {
            return (string)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:      StringValueSerializer.cs
// 
//  Contents:  Stub value serializer for strings 
//
//  Created:   04/28/2005 [....] 
//
//-----------------------------------------------------------------------

using System.Windows.Markup; 

namespace MS.Internal.Serialization 
{ 
    /// 
    /// Stub string serializer. It exists to remove special caseing strings in a couple cases in the 
    /// serialization code. It essentially states that strings are serialized as their value.
    /// 
    internal sealed class StringValueSerializer : ValueSerializer
    { 
        public StringValueSerializer() { }
 
        public override bool CanConvertToString(object value, IValueSerializerContext context) 
        {
            return true; 
        }

        public override bool CanConvertFromString(string value, IValueSerializerContext context)
        { 
            return true;
        } 
 
        public override object ConvertFromString(string value, IValueSerializerContext context)
        { 
            return value;
        }

        public override string ConvertToString(object value, IValueSerializerContext context) 
        {
            return (string)value; 
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK