MaxValueConverter.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 / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / MaxValueConverter.cs / 1305376 / MaxValueConverter.cs

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

namespace System.Activities.Core.Presentation 
{
    using System.Globalization; 
    using System.Windows.Data; 
    using System.Activities.Presentation;
    using System.Activities.Presentation.Model; 
    using System.Activities.Statements;

    //Returns the maximum of input values. Input values should be of type double.
    class MaxValueConverter : IMultiValueConverter 
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 
        { 
            double maxValue = double.MinValue;
            foreach (object value in values) 
            {
                double val = (double)value;
                if (!double.IsNaN(val) && val > maxValue)
                { 
                    maxValue = val;
                } 
            } 
            if (maxValue == double.MinValue)
            { 
                maxValue = double.NaN;
            }
            return maxValue;
        } 

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 
        { 
            throw FxTrace.Exception.AsError(new NotSupportedException());
        } 
    }
}

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