Model.UIColumn SetDefaultConfigContent(Model.UIColumn uiColumn) { string[] words = Regex.Matches(uiColumn.ColumnName, "(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)") .OfType <Match>() .Select(m => m.Value) .ToArray(); string result = string.Join(" ", words); uiColumn.Label = result; uiColumn.ColumnText = result; if (uiColumn.Key) { uiColumn.ConfigContent = new HiddenConfiguration(); } else if (uiColumn.DataType.ToLower().Contains("int") || uiColumn.DataType.ToLower().Contains("long") || uiColumn.DataType.ToLower().Contains("double") || uiColumn.DataType.ToLower().Contains("float")) { uiColumn.ConfigContent = new NumericboxConfiguration(); } else if (uiColumn.DataType.ToLower().Contains("date")) { uiColumn.ConfigContent = new DateConfigurator(); } else if (uiColumn.DataType.ToLower().Contains("text")) { uiColumn.ConfigContent = new TextareaConfiguration(); } else { uiColumn.ConfigContent = new TextboxConfiguration(); } uiColumn.ConfigContent.InitConfiguration(uiColumn); return(uiColumn); }
protected DataSourceUITable Copy(DataSourceTable table) { DataSourceUITable newTable = new DataSourceUITable(); newTable.TableName = table.TableName; newTable.TableSchema = table.TableSchema; foreach (Model.DataColumn col in table.DataColumns) { Model.UIColumn uiColumn = new Model.UIColumn(); uiColumn.DataType = col.DataType; uiColumn.ColumnName = col.ColumnName; uiColumn.ColumnText = col.ColumnText; uiColumn.Key = col.Key; uiColumn.Use = true; uiColumn.Size = col.Size; uiColumn.View = true; uiColumn.Detail = true; uiColumn.Add = true; uiColumn.Edit = true; uiColumn.Delete = true; uiColumn.Label = col.ColumnText; if (col.ConfigContent == null) { uiColumn = SetDefaultConfigContent(uiColumn); } else { uiColumn.ConfigContent = col.ConfigContent; uiColumn.ConfigContent.InitConfiguration(uiColumn); } newTable.DataColumns.Add(uiColumn); } return(newTable); }