ShouldSerializeLocale() private method

private ShouldSerializeLocale ( ) : bool
return bool
示例#1
0
        internal void ReadXmlSchema(XmlReader reader, bool denyResolving)
        {
            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<ds.DataTable.ReadXmlSchema|INFO> %d#, denyResolving=%d{bool}\n", ObjectID, denyResolving);
            try{
                DataSet ds = new DataSet();
                SerializationFormat cachedRemotingFormat = this.RemotingFormat;
                // fxcop: ReadXmlSchema will provide the CaseSensitive, Locale, Namespace information
                ds.ReadXmlSchema(reader, denyResolving);

                string CurrentTableFullName = ds.MainTableName;

                if (Common.ADP.IsEmpty(this.tableName) && Common.ADP.IsEmpty(CurrentTableFullName))
                    return;

                DataTable currentTable = null;

                if (!Common.ADP.IsEmpty(this.tableName)) {
                    if (!Common.ADP.IsEmpty(this.Namespace)) {
                        currentTable = ds.Tables[this.tableName, this.Namespace];
                    }
                    else {//SQL BU defect tracking 240293
                        int tableIndex = ds.Tables.InternalIndexOf(this.tableName);
                        if (tableIndex  > -1) {
                            currentTable = ds.Tables[tableIndex];
                        }
                    }
                }
                else{  //!Common.ADP.IsEmpty(CurrentTableFullName)
                    string CurrentTableNamespace = "";
                    int nsSeperator = CurrentTableFullName.IndexOf(':');
                    if (nsSeperator > -1) {
                        CurrentTableNamespace = CurrentTableFullName.Substring(0, nsSeperator);
                    }
                    string CurrentTableName = CurrentTableFullName.Substring(nsSeperator + 1, CurrentTableFullName.Length - nsSeperator -1);

                    currentTable = ds.Tables[CurrentTableName, CurrentTableNamespace];
                }

                if (currentTable == null) { // bug fix :99186
                    string qTableName = string.Empty;
                    if (!Common.ADP.IsEmpty(this.tableName)) {
                        qTableName = (this.Namespace.Length > 0)? (this.Namespace + ":" + this.tableName):this.tableName;
                    }
                    else {
                        qTableName = CurrentTableFullName ;
                    }
                    throw ExceptionBuilder.TableNotFound(qTableName);
                }

                currentTable._remotingFormat = cachedRemotingFormat;

                List<DataTable> tableList = new List<DataTable>();
                tableList.Add(currentTable);
                CreateTableList(currentTable, tableList);
                List<DataRelation> relationList = new List<DataRelation>();
                CreateRelationList(tableList, relationList);

                if (relationList.Count == 0) {
                    if (this.Columns.Count == 0) {
                        DataTable tempTable = currentTable;
                        if (tempTable != null)
                            tempTable.CloneTo(this, null, false); // we may have issue Amir
                        if (this.DataSet == null && this.tableNamespace == null) { // webdata 105506
// for standalone table, clone wont get these correctly, since they may come with inheritance
                            this.tableNamespace =  tempTable.Namespace;
                        }
                    }
                    return;
                }
                else {
                    if (Common.ADP.IsEmpty(this.TableName)) {
                        this.TableName = currentTable.TableName;
                        if (!Common.ADP.IsEmpty(currentTable.Namespace)) {
                            this.Namespace = currentTable.Namespace;
                        }
                    }
                    if (this.DataSet == null) {
                        DataSet dataset = new DataSet(ds.DataSetName);
// webdata 105506
                        // if user set values on DataTable, it isn't necessary
                        // to set them on the DataSet because they won't be inherited
                        // but it is simpler to set them in both places

                        // if user did not set values on DataTable, it is required
                        // to set them on the DataSet so the table will inherit
                        // the value already on the Datatable
                        dataset.SetLocaleValue(ds.Locale, ds.ShouldSerializeLocale());
                        dataset.CaseSensitive = ds.CaseSensitive;
                        dataset.Namespace = ds.Namespace;
                        dataset.mainTableName = ds.mainTableName;
                        dataset.RemotingFormat = ds.RemotingFormat;

                        dataset.Tables.Add(this);
                    }

                    DataTable targetTable = CloneHierarchy(currentTable, this.DataSet, null);

                    foreach(DataTable tempTable in tableList) {
                        DataTable destinationTable = this.DataSet.Tables[tempTable.tableName, tempTable.Namespace];
                        DataTable sourceTable = ds.Tables[tempTable.tableName, tempTable.Namespace];
                        foreach(Constraint tempConstrain in sourceTable.Constraints) {
                            ForeignKeyConstraint fkc = tempConstrain as ForeignKeyConstraint;  // we have already cloned the UKC when cloning the datatable
                            if (fkc != null) {
                                if (fkc.Table != fkc.RelatedTable)  {
                                    if (tableList.Contains(fkc.Table) && tableList.Contains(fkc.RelatedTable)) {
                                        ForeignKeyConstraint newFKC = (ForeignKeyConstraint)fkc.Clone(destinationTable.DataSet);
                                        if (!destinationTable.Constraints.Contains(newFKC.ConstraintName))
                                            destinationTable.Constraints.Add(newFKC); // we know that the dest table is already in the table
                                    }
                                }
                           }
                        }
                    }
                    foreach(DataRelation rel in relationList) {
                        if (!this.DataSet.Relations.Contains(rel.RelationName))
                            this.DataSet.Relations.Add(rel.Clone(this.DataSet));
                    }

                    bool hasExternaldependency = false;

                    foreach(DataTable tempTable in tableList) {
                        foreach(DataColumn dc in tempTable.Columns) {
                            hasExternaldependency = false;
                            if (dc.Expression.Length  != 0) {
                                DataColumn[] dependency = dc.DataExpression.GetDependency();
                                for (int j = 0; j < dependency.Length; j++) {
                                    if (!tableList.Contains(dependency[j].Table)) {
                                        hasExternaldependency = true;
                                        break;
                                    }
                                }
                            }
                            if (!hasExternaldependency) {
                                this.DataSet.Tables[tempTable.TableName, tempTable.Namespace].Columns[dc.ColumnName].Expression = dc.Expression;
                            }
                        }
                        hasExternaldependency = false;
                    }

                }
            }
            finally{
                Bid.ScopeLeave(ref hscp);
            }
        }