60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DbMigrate {
|
|
public class ColumnCollection {
|
|
public 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();
|
|
}
|
|
}
|
|
}
|