You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

using Apewer.Internals;
using System;
using System.Collections.Generic;
using System.Text;
namespace Apewer.Source
{
/// <summary>数据库中的表。</summary>
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class TableAttribute : Attribute
{
private string _name;
private bool _independent = false;
private bool _locked = false;
/// <summary></summary>
public TableAttribute(string name = null)
{
_name = TableStructure.RestrictName(name, string.IsNullOrEmpty(name));
}
/// <summary></summary>
internal TableAttribute(string name, bool underline)
{
_name = TableStructure.RestrictName(name, underline);
}
/// <summary>表名。</summary>
public string Name
{
get { return _name; }
set
{
if (_locked) return;
_name = TableStructure.RestrictName(value, false);
}
}
/// <summary></summary>
public bool Independent
{
get { return _independent; }
internal set
{
if (_locked) return;
_independent = value;
}
}
/// <summary></summary>
public override int GetHashCode()
{
return _name.GetHashCode();
}
/// <summary>锁定属性,阻止修改。</summary>
public void Lock()
{
_locked = true;
}
}
}