Add project files.
This commit is contained in:
59
Model/ColumnCollection.cs
Normal file
59
Model/ColumnCollection.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DbTools.Model {
|
||||
internal class ColumnCollection {
|
||||
internal Dictionary<string, string> Items { get; private set; } = new Dictionary<string, string>();
|
||||
|
||||
public ColumnCollection() {
|
||||
Items = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string this[string columnName] {
|
||||
get {
|
||||
if (Items.ContainsKey(columnName)) {
|
||||
return Items[columnName];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
if (Items.ContainsKey(columnName)) {
|
||||
Items[columnName] = value;
|
||||
} else {
|
||||
Items.Add(columnName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string columnName, string columnDefinition) {
|
||||
if (!Items.ContainsKey(columnName)) {
|
||||
Items.Add(columnName, columnDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(string columnName) {
|
||||
return Items.ContainsKey(columnName);
|
||||
}
|
||||
|
||||
public string[] GetColumnNames() {
|
||||
return Items.Keys.ToArray();
|
||||
}
|
||||
|
||||
public int Count() {
|
||||
return Items.Count;
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
Items.Clear();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var kvp in Items) {
|
||||
sb.AppendLine($"{kvp.Key}: {kvp.Value}");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user