﻿using Code;

namespace LibDatabaseCodeMaker.Database.SqlStatement
{
	/// <summary>
	/// 用于SQL语句条件的变量
	/// </summary>
	public partial class ConditionVariable
	{
		/// <summary>
		/// 创建ConditionVariable对象和C#对象
		/// </summary>
		/// <param name="type">类型</param>
		/// <param name="name">名称</param>
		/// <param name="comment">注释</param>
		/// <returns>ConditionVariable对象</returns>
		public static ConditionVariable CreateCsVariable(string type, string name, string comment)
		{
			ConditionVariable variable = new ConditionVariable(comment);
			variable.Target = new CSharpLanguage(type, name);
			return variable;
		}

		/// <summary>
		/// C#
		/// </summary>
		public class CSharpLanguage : Language
		{
			/// <summary>
			/// 构造函数
			/// </summary>
			/// <param name="type">类型</param>
			/// <param name="name">名称</param>
			public CSharpLanguage(string type, string name)
			{
				Type = type;
				Name = name;
			}

			/// <summary>
			/// 获取函数参数形式的字符串
			/// </summary>
			/// <returns>参数形式的字符串</returns>
			public override string ToParameter()
			{
				return Formatter.CSharp.ToParameter(Type, Name);
			}
		}
	}
}
