Corregir clases para serializado XML correcto
This commit is contained in:
@@ -5,16 +5,38 @@ using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.Sql;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
[Serializable]
|
||||
public class TablaDesc
|
||||
{
|
||||
public String Esquema = String.Empty;
|
||||
public String Nombre = String.Empty;
|
||||
public List<ColumnaDesc> Columnas = new List<ColumnaDesc>();
|
||||
#region Data parameters
|
||||
|
||||
public TablaDesc() { }
|
||||
private String esquema = String.Empty;
|
||||
[XmlAttribute("Esquema")]
|
||||
public string Esquema
|
||||
{
|
||||
get { return esquema; }
|
||||
set { esquema = value; }
|
||||
}
|
||||
|
||||
private String nombre = String.Empty;
|
||||
[XmlAttribute("Nombre")]
|
||||
public string Nombre
|
||||
{
|
||||
get { return nombre; }
|
||||
set { nombre = value; }
|
||||
}
|
||||
|
||||
private List<ColumnaDesc> columnas = new List<ColumnaDesc>();
|
||||
[XmlArray("Columnas")]
|
||||
public List<ColumnaDesc> Columnas { get { return columnas; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region FillDesc
|
||||
|
||||
// Obtener una columna existente
|
||||
private ColumnaDesc GetCol(String nombre)
|
||||
@@ -85,7 +107,7 @@ namespace ServerExplorer
|
||||
|
||||
// Establecer datos de la columna
|
||||
col.Nombre = (String)dr["Columna"];
|
||||
col.Tipo = (String)dr["Tipo"];
|
||||
col.Tipo = ((String)dr["Tipo"]).ToLower();
|
||||
if (dr["Tamanho"] != DBNull.Value)
|
||||
{
|
||||
col.Tamanho = (int)dr["Tamanho"];
|
||||
@@ -99,8 +121,12 @@ namespace ServerExplorer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region TipoCol
|
||||
|
||||
public enum TipoCol
|
||||
{
|
||||
Unset,
|
||||
@@ -113,92 +139,130 @@ namespace ServerExplorer
|
||||
Otro
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[Serializable]
|
||||
public class ColumnaDesc
|
||||
{
|
||||
public string Nombre = String.Empty;
|
||||
public string Tipo = String.Empty;
|
||||
public int Tamanho = -1;
|
||||
public bool Primaria = false;
|
||||
#region Data properties
|
||||
|
||||
public ColumnaDesc() { }
|
||||
private string nombre = String.Empty;
|
||||
[XmlAttribute("Nombre")]
|
||||
public string Nombre
|
||||
{
|
||||
get { return nombre; }
|
||||
set { nombre = value; }
|
||||
}
|
||||
|
||||
private TipoCol tipo = TipoCol.Unset;
|
||||
private string tipo = String.Empty;
|
||||
[XmlAttribute("Tipo")]
|
||||
public string Tipo
|
||||
{
|
||||
get { return tipo; }
|
||||
set { tipo = value; }
|
||||
}
|
||||
|
||||
private int tamanho = -1;
|
||||
[XmlAttribute("Tamanho")]
|
||||
public int Tamanho
|
||||
{
|
||||
get { return tamanho; }
|
||||
set { tamanho = value; }
|
||||
}
|
||||
|
||||
private bool primaria = false;
|
||||
[XmlAttribute("Primaria")]
|
||||
public bool Primaria
|
||||
{
|
||||
get { return primaria; }
|
||||
set { primaria = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTipo
|
||||
|
||||
private TipoCol _tipo = TipoCol.Unset;
|
||||
public TipoCol GetTipo()
|
||||
{
|
||||
string stipo = Tipo.ToLower();
|
||||
string strTipo = Tipo.ToLower();
|
||||
|
||||
if (this.tipo != TipoCol.Unset)
|
||||
if (_tipo != TipoCol.Unset)
|
||||
{
|
||||
return this.tipo;
|
||||
return _tipo;
|
||||
}
|
||||
|
||||
// Numericos
|
||||
if (
|
||||
stipo == "bigint" ||
|
||||
stipo == "int" ||
|
||||
stipo == "smallint" ||
|
||||
stipo == "tinyint" ||
|
||||
stipo == "bigint"
|
||||
strTipo == "bigint" ||
|
||||
strTipo == "int" ||
|
||||
strTipo == "smallint" ||
|
||||
strTipo == "tinyint" ||
|
||||
strTipo == "bigint"
|
||||
)
|
||||
{
|
||||
return TipoCol.Numerico;
|
||||
_tipo = TipoCol.Numerico;
|
||||
}
|
||||
|
||||
// Aproximados numericos
|
||||
if (
|
||||
stipo == "float" ||
|
||||
stipo == "real"
|
||||
strTipo == "float" ||
|
||||
strTipo == "real"
|
||||
)
|
||||
{
|
||||
return TipoCol.AproxNumerico;
|
||||
_tipo = TipoCol.AproxNumerico;
|
||||
}
|
||||
|
||||
// Tiempo
|
||||
if (
|
||||
stipo == "date" ||
|
||||
stipo == "datetimeoffset" ||
|
||||
stipo == "datetime2" ||
|
||||
stipo == "smalldatetime" ||
|
||||
stipo == "datetime" ||
|
||||
stipo == "time"
|
||||
strTipo == "date" ||
|
||||
strTipo == "datetimeoffset" ||
|
||||
strTipo == "datetime2" ||
|
||||
strTipo == "smalldatetime" ||
|
||||
strTipo == "datetime" ||
|
||||
strTipo == "time"
|
||||
)
|
||||
{
|
||||
return TipoCol.Tiempo;
|
||||
_tipo = TipoCol.Tiempo;
|
||||
}
|
||||
|
||||
// Texto
|
||||
if (
|
||||
stipo == "char" ||
|
||||
stipo == "varchar" ||
|
||||
stipo == "text" ||
|
||||
stipo == "nchar" ||
|
||||
stipo == "nvarchar" ||
|
||||
stipo == "ntext"
|
||||
strTipo == "char" ||
|
||||
strTipo == "varchar" ||
|
||||
strTipo == "text" ||
|
||||
strTipo == "nchar" ||
|
||||
strTipo == "nvarchar" ||
|
||||
strTipo == "ntext"
|
||||
)
|
||||
{
|
||||
return TipoCol.Texto;
|
||||
_tipo = TipoCol.Texto;
|
||||
}
|
||||
|
||||
// Binario
|
||||
if (
|
||||
stipo == "binary" ||
|
||||
stipo == "varbinary" ||
|
||||
stipo == "image"
|
||||
strTipo == "binary" ||
|
||||
strTipo == "varbinary" ||
|
||||
strTipo == "image"
|
||||
)
|
||||
{
|
||||
return TipoCol.Binario;
|
||||
_tipo = TipoCol.Binario;
|
||||
}
|
||||
|
||||
// Booleano
|
||||
if (
|
||||
stipo == "bit"
|
||||
strTipo == "bit"
|
||||
)
|
||||
{
|
||||
return TipoCol.Booleano;
|
||||
_tipo = TipoCol.Booleano;
|
||||
}
|
||||
|
||||
// Otro
|
||||
return TipoCol.Otro;
|
||||
_tipo = TipoCol.Otro;
|
||||
|
||||
return _tipo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user