Example #1
0
 public ColumnConstraints GenerateDiferences(ColumnConstraints CamposOrigen, ColumnConstraints CamposDestino)
 {
     foreach (ColumnConstraint node in CamposDestino)
     {
         if (!CamposOrigen.Find(node.Name))
         {
             node.Status = StatusEnum.ObjectStatusType.CreateStatus;
             CamposOrigen.Parent.Status        = StatusEnum.ObjectStatusType.OriginalStatus;
             CamposOrigen.Parent.Parent.Status = StatusEnum.ObjectStatusType.AlterStatus;
             CamposOrigen.Add(node);
         }
         else
         {
             if (!ColumnConstraint.Compare(CamposOrigen[node.Name], node))
             {
                 node.Status = StatusEnum.ObjectStatusType.AlterStatus;
                 //Indico que hay un ALTER TABLE, pero sobre la columna, no seteo ningun estado.
                 CamposOrigen[node.Name].Parent.Parent.Status = StatusEnum.ObjectStatusType.AlterStatus;
                 CamposOrigen[node.Name] = node.Clone((Column)CamposOrigen[node.Name].Parent);
             }
         }
     }
     foreach (ColumnConstraint node in CamposOrigen)
     {
         if (!CamposDestino.Find(node.Name))
         {
             node.Status = StatusEnum.ObjectStatusType.DropStatus;
             CamposOrigen.Parent.Status        = StatusEnum.ObjectStatusType.OriginalStatus;
             CamposOrigen.Parent.Parent.Status = StatusEnum.ObjectStatusType.AlterStatus;
         }
     }
     return(CamposOrigen);
 }
        public string GetText()
        {
            var sb = new StringBuilder(Template);

            sb.Replace("{column-name}", ColumnName);
            sb.Replace("{type-name}", TypeName);
            sb.Replace("{column-constraint}", ColumnConstraints.CommandText());

            return(sb.ToString().Trim());
        }
Example #3
0
        private void CreateConstraints()
        {
            var rowConstrainers = RowConstraints.Select(c => new Constrainer(c)).ToList();
            var colConstrainers = ColumnConstraints.Select(c => new Constrainer(c)).ToList();

            rowConstraintList = Enumerable.Range(0, NumRows).Select(i => new ConstraintListWrapper(i, true, rowConstrainers[i])).ToList();
            colConstraintList = Enumerable.Range(0, NumColumns).Select(i => new ConstraintListWrapper(i, false, colConstrainers[i])).ToList();

            Debug.Assert(rowConstraintList.Count == NumRows);
            Debug.Assert(colConstraintList.Count == NumColumns);
        }
Example #4
0
        public void DeduceColumnConstraints()
        {
            CSVImporter       importer          = new CSVImporter(/*isFirstRowHeader*/ true);
            Table             table             = importer.importFromFile(Path.Combine(filePath, "Categories.txt"));
            ColumnConstraints columnConstraints = new ColumnConstraints();

            columnConstraints.DeducePrimaryKey(table);
            // We know that the first column Contains is a primary key
            bool isPrimaryKey =
                table.Columns[0].Meta.Constraints.ContainsKey(ConstraintKind.PrimaryKey);

            Assert.IsTrue(isPrimaryKey, "Column 0 not primary key!");
        }
Example #5
0
        private void DiscoverAttributes()
        {
            string            columnName  = null;
            ColumnConstraints constraints = new ColumnConstraints();
            SqlTypeCode?      typeCode    = null;
            int?size  = null;
            int?scale = null;

            var attributes = memberInfo.GetCustomAttributes(false);

            foreach (var attribute in attributes)
            {
                if (attribute is ColumnNameAttribute)
                {
                    var columnNameAttr = (ColumnNameAttribute)attribute;
                    ColumnName = columnNameAttr.ColumnName;
                }
                else if (attribute is ColumnAttribute)
                {
                    var columnAttr = (ColumnAttribute)attribute;
                    columnName = columnAttr.ColumnName;
                    typeCode   = columnAttr.SqlType;
                    size       = columnAttr.Size;
                    scale      = columnAttr.Scale;
                }
                else if (attribute is ColumnConstraintAttribute)
                {
                    var constraintAttr = (ColumnConstraintAttribute)attribute;
                    constraints |= constraintAttr.Constraints;
                }
            }

            ColumnName        = columnName;
            ColumnTypeCode    = typeCode;
            ColumnConstraints = constraints;
            Size      = size;
            Precision = scale;
        }
Example #6
0
        protected override void OnChildAdded(IWidget child, int index, Point constraint)
        {
            List <IWidget> widgets;

            if (widgetsPerPosition.TryGetValue(constraint, out widgets))
            {
                widgets.Add(child);
            }
            else
            {
                widgets = new List <IWidget>(1);
                widgets.Add(child);
                widgetsPerPosition[constraint] = widgets;
            }

            var row    = constraint.Y;
            var column = constraint.X;

            if (row >= RowCount)
            {
                rows = null;
            }

            if (column >= ColumnCount)
            {
                columns = null;
            }

            while (RowConstraints.Count <= row)
            {
                RowConstraints.Add(LengthConstraint.Auto);
            }

            while (ColumnConstraints.Count <= column)
            {
                ColumnConstraints.Add(LengthConstraint.Auto);
            }
        }
 public ColumnConstraintAttribute(ColumnConstraints constraints)
 {
     this.Constraints = constraints;
 }
Example #8
0
 public override int GetHashCode()
 {
     return(Size.GetHashCode() ^ ColumnConstraints.GetHashCode() ^ RowConstraints.GetHashCode());
 }
Example #9
0
 public ColumnConstraintAttribute(ColumnConstraints constraints)
 {
     this.Constraints = constraints;
 }