ymikulski    2002/08/13 05:59:51

  Added:       csframework/src/cs/Util Converter.cs
  Log:
  no message
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/csframework/src/cs/Util/Converter.cs
  
  Index: Converter.cs
  ===================================================================
  ///
  /// Copyright (C) The Apache Software Foundation. All rights reserved.
  ///
  /// This software is published under the terms of the Apache Software License
  /// version 1.1, a copy of which has been included  with this distribution in
  /// the LICENSE.txt file.
  ///
  using System;
  
  namespace Apache.Avalon.Util
  {
        internal class Converter
        {
  
                internal static object ChangeType(object value, Type type, object 
defaultValue)
                {
                        object result;
  
                        try
                        {
                                result = Convert.ChangeType(value, type); 
                        }
                        catch (Exception e)
                        {
                                if (defaultValue == null)
                                {
                                        throw new InvalidCastException("The Convertion 
failed.", e);
                                }
                                else
                                {
                                        result = defaultValue;
                                }
                        }
                        
                        return result;
                }
        }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to