Example #1
0
        /// <summary>
        /// Load from XML element
        /// </summary>
        /// <param name="node"></param>
        /// <returns>De-serialized datatype</returns>
        public static Datatype LoadFromXmlNode(XElement node)
        {
            var res = new Datatype();

            res.Name         = node.Attribute("Name").Value;
            res.IsNullable   = node.Attribute("IsNullable").Value.Equals("1");
            res.HasLenght    = node.Attribute("HasLenght").Value.Equals("1");
            res.HasScale     = node.Attribute("HasScale").Value.Equals("1");
            res.HasPrecision = node.Attribute("HasPrecision").Value.Equals("1");

            if (res.HasLenght)
            {
                res.MaxLenght     = int.Parse(node.Attribute("MaxLenght").Value);
                res.DefaultLenght = int.Parse(node.Attribute("DefaultLenght").Value);
                res.Lenght        = res.DefaultLenght;
            }

            if (res.HasPrecision)
            {
                res.MaxPrecision     = int.Parse(node.Attribute("Precision").Value);
                res.DefaultPrecision = int.Parse(node.Attribute("DefaultPrecision").Value);
                res.Precision        = res.DefaultPrecision;
            }

            if (res.HasScale)
            {
                res.MaxScale     = int.Parse(node.Attribute("Scale").Value);
                res.DefaultScale = int.Parse(node.Attribute("DefaultScale").Value);
                res.Scale        = res.DefaultScale;
            }

            return(res);
        }
Example #2
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="name">Column name</param>
        /// <param name="datatype">Source datatype</param>
        public TableRowModel(string name, Datatype datatype)
        {
            Name             = name;
            Datatype         = datatype;
            SelectedDatatype =
                DatatypesItemSource.FirstOrDefault(t => t.Name.Equals(datatype.Name, StringComparison.CurrentCultureIgnoreCase));

            if (SelectedDatatype == null)
            {
                return;
            }

            if (Datatype.HasLenght)
            {
                SelectedDatatype.Lenght = datatype.Lenght;
            }

            if (Datatype.HasScale)
            {
                SelectedDatatype.Scale = datatype.Scale;
            }

            if (Datatype.HasPrecision)
            {
                SelectedDatatype.Precision = datatype.Precision;
            }
        }
Example #3
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="datatype">Source datatype</param>
 public Datatype(Datatype datatype)
 {
     Name             = datatype.Name;
     DefaultLenght    = datatype.DefaultLenght;
     DefaultPrecision = datatype.DefaultPrecision;
     DefaultScale     = datatype.DefaultScale;
     HasLenght        = datatype.HasLenght;
     HasScale         = datatype.HasScale;
     HasPrecision     = datatype.HasPrecision;
     MaxLenght        = datatype.MaxLenght;
     MaxScale         = datatype.MaxScale;
     MaxPrecision     = datatype.MaxPrecision;
     IsNullable       = datatype.IsNullable;
     Lenght           = datatype.Lenght;
     Scale            = datatype.Scale;
     Precision        = datatype.Precision;
 }