#region Apache Notice
/*****************************************************************************
* $Header: $
* $Revision: 591621 $
* $Date$
*
* iBATIS.NET Data Mapper
* Copyright (C) 2008/2005 - The Apache Software Foundation
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************************/
#endregion
using System;
using Apache.Ibatis.Common.Contracts;
using Apache.Ibatis.DataMapper.Configuration.Interpreters.Config;
namespace Apache.Ibatis.DataMapper.Configuration.Module
{
///
/// Handles fluent configuration for ParameterMap element
///
public class ParameterExpression : ParameterMapExpression
{
///
/// Initializes a new instance of the class.
///
/// The module builder.
public ParameterExpression(ModuleBuilder builder)
: base(builder)
{
parameterExpression = this;
}
///
/// To the Column name.
///
/// The name.
///
public ParameterExpression ToColumn(string name)
{
Contract.Require.That(name, Is.Not.Null & Is.Not.Empty).When("retrieving name argument in ToColumn method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_COLUMN, name);
return this;
}
///
/// With the type handler.
///
///
public ParameterExpression WithTypeHandler()
{
Type typeHandler = typeof(THandler);
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_TYPEHANDLER, typeHandler.AssemblyQualifiedName);
return this;
}
///
/// Uses the dbtype.
///
/// The name.
///
public ParameterExpression UsingDbType(string name)
{
Contract.Require.That(name, Is.Not.Null & Is.Not.Empty).When("retrieving name argument in UsingDbType method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_DBTYPE, name);
return this;
}
///
/// Uses the type.
///
/// The name.
///
public ParameterExpression UsingType(string name)
{
Contract.Require.That(name, Is.Not.Null & Is.Not.Empty).When("retrieving name argument in UsingType method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_TYPE, name);
return this;
}
///
/// Uses the null value.
///
/// The null value.
///
public ParameterExpression UsingNullValue(string val)
{
Contract.Require.That(val, Is.Not.Null & Is.Not.Empty).When("retrieving null value argument in UsingNullValue method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_NULLVALUE, val);
return this;
}
///
/// With the direction.
///
/// The direction.
///
public ParameterExpression WithDirection(string direction)
{
Contract.Require.That(direction, Is.Not.Null & Is.Not.Empty).When("retrieving direction argument in UsingNullValue method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_DIRECTION, direction);
return this;
}
///
/// With the size
///
/// The size.
///
public ParameterExpression WithSize(string size)
{
Contract.Require.That(size, Is.Not.Null & Is.Not.Empty).When("retrieving size argument in WithSize method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_SIZE, size);
return this;
}
///
/// With the scale
///
/// The scale.
///
public ParameterExpression WithScale(string scale)
{
Contract.Require.That(scale, Is.Not.Null & Is.Not.Empty).When("retrieving scale argument in WithScale method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_SCALE, scale);
return this;
}
///
/// With the precision
///
/// The precision.
///
public ParameterExpression WithPrecision(string precision)
{
Contract.Require.That(precision, Is.Not.Null & Is.Not.Empty).When("retrieving precision argument in WithPrecision method");
builder.CurrentConfiguration.CreateAttribute(ConfigConstants.ATTRIBUTE_PRECISION, precision);
return this;
}
}
}