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.
230 lines
4.1 KiB
230 lines
4.1 KiB
6 months ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Xml.Serialization;
|
||
|
using KGIS.Plugin.LayerProperty.Enum;
|
||
|
using KGIS.Plugin.LayerProperty.Interface;
|
||
|
using KGIS.Plugin.LayerProperty.Utils;
|
||
|
|
||
|
namespace KGIS.Plugin.LayerProperty.Model
|
||
|
{
|
||
|
public abstract class AbstractTable
|
||
|
{
|
||
|
public class Collections : IEnumerable<AbstractField>, IEnumerable
|
||
|
{
|
||
|
private IList<AbstractField> mList;
|
||
|
public int Count
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.mList.Count;
|
||
|
}
|
||
|
}
|
||
|
public AbstractField this[int index]
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.mList[index];
|
||
|
}
|
||
|
}
|
||
|
public AbstractField this[long fieldid]
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
foreach (AbstractField current in this.mList)
|
||
|
{
|
||
|
if (current.ID == fieldid)
|
||
|
{
|
||
|
return current;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
public AbstractField this[string name]
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
foreach (AbstractField current in this.mList)
|
||
|
{
|
||
|
if (current.Name == name)
|
||
|
{
|
||
|
return current;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
public Collections()
|
||
|
{
|
||
|
this.mList = new List<AbstractField>();
|
||
|
}
|
||
|
public IEnumerator<AbstractField> GetEnumerator()
|
||
|
{
|
||
|
foreach (AbstractField current in this.mList)
|
||
|
{
|
||
|
yield return current;
|
||
|
}
|
||
|
yield break;
|
||
|
}
|
||
|
IEnumerator IEnumerable.GetEnumerator()
|
||
|
{
|
||
|
foreach (AbstractField current in this.mList)
|
||
|
{
|
||
|
yield return current;
|
||
|
}
|
||
|
yield break;
|
||
|
}
|
||
|
public void Add(AbstractField item)
|
||
|
{
|
||
|
this.mList.Add(item);
|
||
|
}
|
||
|
internal bool Remove(AbstractField item)
|
||
|
{
|
||
|
return this.mList.Remove(item);
|
||
|
}
|
||
|
internal void Clear()
|
||
|
{
|
||
|
this.mList.Clear();
|
||
|
}
|
||
|
internal bool Exist(AbstractField item)
|
||
|
{
|
||
|
return this[item.Name] != null;
|
||
|
}
|
||
|
}
|
||
|
private AbstractTable.Collections collections;
|
||
|
private DataSourceGeneric dataSource;
|
||
|
private long id;
|
||
|
private string name;
|
||
|
private string aliasName;
|
||
|
private string category;
|
||
|
private string description;
|
||
|
[XmlIgnore]
|
||
|
public AbstractTable.Collections Collection
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.collections;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.collections = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlIgnore]
|
||
|
public DataSourceGeneric DataSource
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.dataSource;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.dataSource = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlElement]
|
||
|
public long ID
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.id;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.id = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlAttribute]
|
||
|
public string Name
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.name;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.name = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlAttribute]
|
||
|
public string AliasName
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.aliasName;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.aliasName = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlAttribute]
|
||
|
public string Category
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.category;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.category = value;
|
||
|
}
|
||
|
}
|
||
|
[XmlAttribute]
|
||
|
public string Description
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.description;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
this.description = value;
|
||
|
}
|
||
|
}
|
||
|
protected void Clear()
|
||
|
{
|
||
|
this.collections.Clear();
|
||
|
}
|
||
|
protected bool Remove(AbstractField field)
|
||
|
{
|
||
|
return this.collections.Remove(field);
|
||
|
}
|
||
|
protected bool Add(AbstractField field)
|
||
|
{
|
||
|
if (!this.Exist(field))
|
||
|
{
|
||
|
this.collections.Add(field);
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
protected bool Exist(AbstractField field)
|
||
|
{
|
||
|
return this.collections.Exist(field);
|
||
|
}
|
||
|
protected AbstractTable()
|
||
|
{
|
||
|
this.collections = new AbstractTable.Collections();
|
||
|
}
|
||
|
public AbstractTable(DataSourceGeneric dataSource, string name, string aliasName, string category, string description)
|
||
|
{
|
||
|
this.collections = new AbstractTable.Collections();
|
||
|
this.DataSource = dataSource;
|
||
|
this.name = name;
|
||
|
this.aliasName = aliasName;
|
||
|
this.category = category;
|
||
|
this.description = description;
|
||
|
}
|
||
|
public abstract AbstractField Create(string name, string aliasName, DBDataType dbType, IKgisDictionary dictionary, FieldKeyType fieldKeyType, string defaultValue, int length, string description);
|
||
|
public override string ToString()
|
||
|
{
|
||
|
if (this.aliasName == null || this.aliasName.Equals(""))
|
||
|
{
|
||
|
return this.name;
|
||
|
}
|
||
|
return this.aliasName;
|
||
|
}
|
||
|
}
|
||
|
}
|