Exemple #1
0
        private void ProcessMemberNames(DesignTable designTable)
        {
            if (designTable.DesignColumns != null)
            {
                foreach (DesignColumn column in designTable.DesignColumns)
                {
                    this.ProcessColumnRelatedNames(column);
                }
            }
            DataRelationCollection childRelations = designTable.DataTable.ChildRelations;

            if (childRelations != null)
            {
                foreach (DataRelation relation in childRelations)
                {
                    DesignRelation relation2 = this.FindCorrespondingDesignRelation(designTable, relation);
                    this.ProcessChildRelationName(relation2);
                }
            }
            DataRelationCollection parentRelations = designTable.DataTable.ParentRelations;

            if (parentRelations != null)
            {
                foreach (DataRelation relation3 in parentRelations)
                {
                    DesignRelation relation4 = this.FindCorrespondingDesignRelation(designTable, relation3);
                    this.ProcessParentRelationName(relation4);
                }
            }
            this.ProcessEventNames(designTable);
        }
Exemple #2
0
 private void ReadXmlSchema(DataSourceXmlTextReader xmlReader)
 {
     this.designConnections = new DesignConnectionCollection(this);
     this.designTables      = new DesignTableCollection(this);
     this.designRelations   = new DesignRelationCollection(this);
     this.sources           = new SourceCollection(this);
     this.serializer        = new DataSourceXmlSerializer();
     this.dataSet           = new System.Data.DataSet();
     this.dataSet.Locale    = CultureInfo.InvariantCulture;
     System.Data.DataSet set = new System.Data.DataSet {
         Locale = CultureInfo.InvariantCulture
     };
     set.ReadXmlSchema(xmlReader);
     this.dataSet = set;
     foreach (DataTable table in this.dataSet.Tables)
     {
         DesignTable table2 = this.designTables[table.TableName];
         if (table2 == null)
         {
             this.designTables.Add(new DesignTable(table, TableType.DataTable));
         }
         else
         {
             table2.DataTable = table;
         }
         foreach (Constraint constraint in table.Constraints)
         {
             ForeignKeyConstraint foreignKeyConstraint = constraint as ForeignKeyConstraint;
             if (foreignKeyConstraint != null)
             {
                 this.designRelations.Add(new DesignRelation(foreignKeyConstraint));
             }
         }
     }
     foreach (DataRelation relation in this.dataSet.Relations)
     {
         DesignRelation relation2 = this.designRelations[relation.ChildKeyConstraint];
         if (relation2 != null)
         {
             relation2.DataRelation = relation;
         }
         else
         {
             this.designRelations.Add(new DesignRelation(relation));
         }
     }
     foreach (Source source in this.Sources)
     {
         this.SetConnectionProperty(source);
     }
     foreach (DesignTable table3 in this.DesignTables)
     {
         this.SetConnectionProperty(table3.MainSource);
         foreach (Source source2 in table3.Sources)
         {
             this.SetConnectionProperty(source2);
         }
     }
     this.serializer.InitializeObjects();
 }
Exemple #3
0
 internal void ProcessRelationRelatedNames(DesignRelation relation)
 {
     if (relation.DataRelation != null)
     {
         if (!StringUtil.EqualValue(relation.Name, relation.UserRelationName, this.languageCaseInsensitive) || StringUtil.Empty(relation.GeneratorRelationVarName))
         {
             relation.GeneratorRelationVarName = this.validator.GenerateIdName(this.RelationVariableName(relation.DataRelation));
         }
         else
         {
             relation.GeneratorRelationVarName = this.validator.GenerateIdName(relation.GeneratorRelationVarName);
         }
     }
 }
Exemple #4
0
        internal void ProcessParentRelationName(DesignRelation relation)
        {
            bool   flag            = (!StringUtil.EqualValue(relation.Name, relation.UserRelationName, this.languageCaseInsensitive) || !StringUtil.EqualValue(relation.ChildDesignTable.Name, relation.UserChildTable, this.languageCaseInsensitive)) || !StringUtil.EqualValue(relation.ParentDesignTable.Name, relation.UserParentTable, this.languageCaseInsensitive);
            bool   usesAnnotations = false;
            string name            = this.ParentPropertyName(relation.DataRelation, out usesAnnotations);

            if (usesAnnotations)
            {
                relation.GeneratorParentPropName = name;
            }
            else if (flag || StringUtil.Empty(relation.GeneratorParentPropName))
            {
                relation.GeneratorParentPropName = this.validator.GenerateIdName(name);
            }
            else
            {
                relation.GeneratorParentPropName = this.validator.GenerateIdName(relation.GeneratorParentPropName);
            }
        }
        protected override void OnInsert(int index, object value)
        {
            base.ValidateType(value);
            DesignRelation relation = (DesignRelation)value;

            if ((this.dataSource == null) || (relation.Owner != this.dataSource))
            {
                if ((this.dataSource != null) && (relation.Owner != null))
                {
                    throw new InternalException("This relation belongs to another DataSource already", 0x4e2a);
                }
                if ((relation.Name == null) || (relation.Name.Length == 0))
                {
                    relation.Name = this.CreateUniqueName(relation);
                }
                this.ValidateName(relation);
                System.Data.DataSet dataSet = this.DataSet;
                if (dataSet != null)
                {
                    if (relation.ForeignKeyConstraint != null)
                    {
                        ForeignKeyConstraint foreignKeyConstraint = relation.ForeignKeyConstraint;
                        if (foreignKeyConstraint.Columns.Length > 0)
                        {
                            DataTable table = foreignKeyConstraint.Columns[0].Table;
                            if ((table != null) && !table.Constraints.Contains(foreignKeyConstraint.ConstraintName))
                            {
                                table.Constraints.Add(foreignKeyConstraint);
                            }
                        }
                    }
                    if ((relation.DataRelation != null) && !dataSet.Relations.Contains(relation.DataRelation.RelationName))
                    {
                        dataSet.Relations.Add(relation.DataRelation);
                    }
                }
                base.OnInsert(index, value);
                relation.Owner = this.dataSource;
            }
        }
 internal void ProcessRelationRelatedNames(DesignRelation relation)
 {
     if (relation.DataRelation != null)
     {
         if (!StringUtil.EqualValue(relation.Name, relation.UserRelationName, this.languageCaseInsensitive) || StringUtil.Empty(relation.GeneratorRelationVarName))
         {
             relation.GeneratorRelationVarName = this.validator.GenerateIdName(this.RelationVariableName(relation.DataRelation));
         }
         else
         {
             relation.GeneratorRelationVarName = this.validator.GenerateIdName(relation.GeneratorRelationVarName);
         }
     }
 }
 public void Remove(DesignRelation rel)
 {
     base.List.Remove(rel);
 }
 public bool Contains(DesignRelation rel)
 {
     return(base.List.Contains(rel));
 }
 public int Add(DesignRelation rel)
 {
     return(base.List.Add(rel));
 }
 public void Remove(DesignRelation rel)
 {
     base.List.Remove(rel);
 }
 public bool Contains(DesignRelation rel)
 {
     return base.List.Contains(rel);
 }
 public int Add(DesignRelation rel)
 {
     return base.List.Add(rel);
 }
 internal void ProcessParentRelationName(DesignRelation relation)
 {
     bool flag = (!StringUtil.EqualValue(relation.Name, relation.UserRelationName, this.languageCaseInsensitive) || !StringUtil.EqualValue(relation.ChildDesignTable.Name, relation.UserChildTable, this.languageCaseInsensitive)) || !StringUtil.EqualValue(relation.ParentDesignTable.Name, relation.UserParentTable, this.languageCaseInsensitive);
     bool usesAnnotations = false;
     string name = this.ParentPropertyName(relation.DataRelation, out usesAnnotations);
     if (usesAnnotations)
     {
         relation.GeneratorParentPropName = name;
     }
     else if (flag || StringUtil.Empty(relation.GeneratorParentPropName))
     {
         relation.GeneratorParentPropName = this.validator.GenerateIdName(name);
     }
     else
     {
         relation.GeneratorParentPropName = this.validator.GenerateIdName(relation.GeneratorParentPropName);
     }
 }