ServiceOperationInfoTypeConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / Workflow / Activities / ServiceOperationInfoTypeConverter.cs / 1305376 / ServiceOperationInfoTypeConverter.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.Workflow.Activities 
{
    using System; 
    using System.ComponentModel; 
    using System.Globalization;
 
    class ServiceOperationInfoTypeConverter : TypeConverter
    {
        public ServiceOperationInfoTypeConverter()
        { 
        }
 
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) 
        {
            return false; 
        }

        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        { 
            if (destinationType == typeof(string))
            { 
                return true; 
            }
 
            return base.CanConvertTo(context, destinationType);
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, 
            object value, Type destinationType)
        { 
            if (destinationType == typeof(string)) 
            {
                OperationInfoBase serviceOperationInfo = value as OperationInfoBase; 
                if (serviceOperationInfo != null)
                {
                    string contractName = serviceOperationInfo.GetContractFullName(null);
                    if (string.IsNullOrEmpty(contractName) || string.IsNullOrEmpty(serviceOperationInfo.Name)) 
                    {
                        return string.Empty; 
                    } 

                    return string.Format(CultureInfo.InvariantCulture, 
                        "{0}.{1}",
                        contractName,
                        serviceOperationInfo.Name);
                } 
            }
            return base.ConvertTo(context, culture, value, destinationType); 
        } 

        public override bool GetPropertiesSupported(ITypeDescriptorContext context) 
        {
            return false;
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

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