TypeConverterMarkupExtension.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / Baml2006 / TypeConverterMarkupExtension.cs / 1305600 / TypeConverterMarkupExtension.cs

                            using System; 
using System.Collections.Generic;
using System.ComponentModel;

namespace System.Windows.Baml2006 
{
    internal class TypeConverterMarkupExtension : System.Windows.Markup.MarkupExtension 
    { 
        private TypeConverter _converter;
        private object _value; 

        public TypeConverterMarkupExtension(TypeConverter converter, object value)
        {
            _converter = converter; 
            _value = value;
        } 
 
        public override object ProvideValue(IServiceProvider serviceProvider)
        { 
            return _converter.ConvertFrom(new TypeConverterContext(serviceProvider), System.Globalization.CultureInfo.InvariantCulture, _value);
        }

        private class TypeConverterContext : ITypeDescriptorContext 
        {
            private IServiceProvider _serviceProvider; 
            public TypeConverterContext(IServiceProvider serviceProvider) 
            {
                _serviceProvider = serviceProvider; 
            }

            object IServiceProvider.GetService(Type serviceType)
            { 
                return _serviceProvider.GetService(serviceType);
            } 
 
            #region ITypeDescriptorContext Methods
            // ITypeDescriptorContext derives from IServiceProvider. 
            void ITypeDescriptorContext.OnComponentChanged()
            {
            }
 
            bool ITypeDescriptorContext.OnComponentChanging()
            { 
                return false; 
            }
 
            IContainer ITypeDescriptorContext.Container
            {
                get { return null; }
            } 

            object ITypeDescriptorContext.Instance 
            { 
                get { return null; }
            } 

            PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor
            {
                get { return null; } 
            }
            #endregion 
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
´╗┐using System; 
using System.Collections.Generic;
using System.ComponentModel;

namespace System.Windows.Baml2006 
{
    internal class TypeConverterMarkupExtension : System.Windows.Markup.MarkupExtension 
    { 
        private TypeConverter _converter;
        private object _value; 

        public TypeConverterMarkupExtension(TypeConverter converter, object value)
        {
            _converter = converter; 
            _value = value;
        } 
 
        public override object ProvideValue(IServiceProvider serviceProvider)
        { 
            return _converter.ConvertFrom(new TypeConverterContext(serviceProvider), System.Globalization.CultureInfo.InvariantCulture, _value);
        }

        private class TypeConverterContext : ITypeDescriptorContext 
        {
            private IServiceProvider _serviceProvider; 
            public TypeConverterContext(IServiceProvider serviceProvider) 
            {
                _serviceProvider = serviceProvider; 
            }

            object IServiceProvider.GetService(Type serviceType)
            { 
                return _serviceProvider.GetService(serviceType);
            } 
 
            #region ITypeDescriptorContext Methods
            // ITypeDescriptorContext derives from IServiceProvider. 
            void ITypeDescriptorContext.OnComponentChanged()
            {
            }
 
            bool ITypeDescriptorContext.OnComponentChanging()
            { 
                return false; 
            }
 
            IContainer ITypeDescriptorContext.Container
            {
                get { return null; }
            } 

            object ITypeDescriptorContext.Instance 
            { 
                get { return null; }
            } 

            PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor
            {
                get { return null; } 
            }
            #endregion 
        } 
    }
} 

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