StaticExtensionConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Markup / StaticExtensionConverter.cs / 1 / StaticExtensionConverter.cs

                            //------------------------------------------------------------------------ 
//
//  Microsoft Windows Client Platform
//  Copyright (C) Microsoft Corporation, 2005
// 
//  File:      StaticExtensionConverter.cs
// 
//  Contents:  Converter to convert StaticExtensions to InstanceDescriptors 

//  Created:   04/28/2005 [....] 
//
//-----------------------------------------------------------------------

using System; 
using System.ComponentModel;
using System.ComponentModel.Design.Serialization; 
using System.Collections.Generic; 
using System.Text;
using System.Security; 

namespace System.Windows.Markup
{
    class StaticExtensionConverter : TypeConverter 
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) 
        { 
            if (destinationType == typeof(InstanceDescriptor))
            { 
                return true;
            }
            return base.CanConvertTo(context, destinationType);
        } 

        /// 
        ///     Critical: calls InstanceDescriptor ctor which LinkDemands 
        ///     TreatAsSafe: can only make an InstanceDescriptor for StaticExtension, not an arbitrary class
        /// 
        [SecurityCritical, SecurityTreatAsSafe]
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(InstanceDescriptor)) 
            {
                StaticExtension staticExtension = value as StaticExtension; 
                if (staticExtension == null) 
                    throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension"));
                return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), 
                    new object[] { staticExtension.Member });
            }
            return base.ConvertTo(context, culture, value, destinationType);
        } 
    }
} 
 

// 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:      StaticExtensionConverter.cs
// 
//  Contents:  Converter to convert StaticExtensions to InstanceDescriptors 

//  Created:   04/28/2005 [....] 
//
//-----------------------------------------------------------------------

using System; 
using System.ComponentModel;
using System.ComponentModel.Design.Serialization; 
using System.Collections.Generic; 
using System.Text;
using System.Security; 

namespace System.Windows.Markup
{
    class StaticExtensionConverter : TypeConverter 
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) 
        { 
            if (destinationType == typeof(InstanceDescriptor))
            { 
                return true;
            }
            return base.CanConvertTo(context, destinationType);
        } 

        /// 
        ///     Critical: calls InstanceDescriptor ctor which LinkDemands 
        ///     TreatAsSafe: can only make an InstanceDescriptor for StaticExtension, not an arbitrary class
        /// 
        [SecurityCritical, SecurityTreatAsSafe]
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(InstanceDescriptor)) 
            {
                StaticExtension staticExtension = value as StaticExtension; 
                if (staticExtension == null) 
                    throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "StaticExtension"));
                return new InstanceDescriptor(typeof(StaticExtension).GetConstructor(new Type[] { typeof(string) }), 
                    new object[] { staticExtension.Member });
            }
            return base.ConvertTo(context, culture, value, destinationType);
        } 
    }
} 
 

// 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