ymikulski    2002/08/28 02:06:52

  Modified:    csframework/src/cs/Parameters Parameters.cs
               csframework/src/cs/Util Converter.cs
  Log:
  no message
  
  Revision  Changes    Path
  1.3       +29 -16    
jakarta-avalon-excalibur/csframework/src/cs/Parameters/Parameters.cs
  
  Index: Parameters.cs
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/csframework/src/cs/Parameters/Parameters.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parameters.cs     19 Aug 2002 19:01:37 -0000      1.2
  +++ Parameters.cs     28 Aug 2002 09:06:52 -0000      1.3
  @@ -52,11 +52,14 @@
                /// Gets or sets the parameter associated with the specified name.
                /// </summary>
                /// <value>The parameter associated with the specified name.</value>
  +             /// <exception cref="ParameterException">
  +             /// If the name of the parameter is incorrect.
  +             /// </exception>
                public object this[string name]
                {
                        get
                        {
  -                             return GetParameter(name, null); 
  +                             return this[name, null]; 
                        }
                        set 
                        {
  @@ -83,12 +86,18 @@
                /// </summary>
                /// <param name="name">The Parameter name</param>
                /// <param name="type">The <see cref="System.Type"/></param>
  -             /// <returns>The parameter value converted into the specified 
type.</returns>
  -             public object GetParameter(string name, Type type)
  +             /// <value>The parameter value converted into the specified 
type.</value>
  +             /// <exception cref="ParameterException">
  +             /// If the name of the parameter is incorrect.
  +             /// </exception>
  +             public object this[string name, Type type]
                {
  -                     return GetParameter(name, type, null);
  +                     get
  +                     {
  +                             return this[name, type, null];
  +                     }
                }
  -
  +             
                /// <summary>
                /// Gets the parameter with the specified name and 
                /// converts it into specified <see cref="System.Type"/>.
  @@ -98,26 +107,30 @@
                /// <param name="defaultValue">
                /// The defaultValue returned if the parameter has wrong type.
                /// </param> 
  -             /// <returns>The parameter value converted into the specified 
type.</returns>
  +             /// <value>The parameter value converted into the specified 
type.</value>
                /// <exception cref="ParameterException">
                /// If the name of the parameter is incorrect.
                /// </exception>
  -             public object GetParameter(string name, Type type, object defaultValue)
  +             public object this[string name, Type type, object defaultValue]
                {
  -                     if (name == null)
  +                     get
                        {
  -                             throw new ParameterException( "You cannot lookup a 
null parameter" );
  -                     }
  +                             if (name == null)
  +                             {
  +                                     throw new ParameterException( "You cannot 
lookup a null parameter" );
  +                             }
   
  -                     object result = parameters[name];
  +                             object result = parameters[name];
   
  -                     if( result == null )
  -                     {
  -                             throw new ParameterException( string.Format("The 
parameter {0} does not contain a value.", name));
  -                     }
  +                             if( result == null )
  +                             {
  +                                     throw new ParameterException( 
string.Format("The parameter {0} does not contain a value.", name));
  +                             }
   
  -                     return Converter.ChangeType(result, type, defaultValue);
  +                             return Converter.ChangeType(result, type, 
defaultValue);
  +                     }
                }
  +
                
                /// <summary>
                /// Removes the parameter with the specified name.
  
  
  
  1.2       +14 -8     jakarta-avalon-excalibur/csframework/src/cs/Util/Converter.cs
  
  Index: Converter.cs
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/csframework/src/cs/Util/Converter.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Converter.cs      13 Aug 2002 12:59:51 -0000      1.1
  +++ Converter.cs      28 Aug 2002 09:06:52 -0000      1.2
  @@ -16,22 +16,28 @@
                {
                        object result;
   
  -                     try
  +                     if (type == null)
                        {
  -                             result = Convert.ChangeType(value, type); 
  +                             result = value;
                        }
  -                     catch (Exception e)
  +                     else
                        {
  -                             if (defaultValue == null)
  +                             try
                                {
  -                                     throw new InvalidCastException("The Convertion 
failed.", e);
  +                                     result = Convert.ChangeType(value, type); 
                                }
  -                             else
  +                             catch (Exception e)
                                {
  -                                     result = defaultValue;
  +                                     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