Exemple #1
0
		public DBTableField[] TableFields() {
			DBTableField _tableField;
			System.Collections.Generic.List<DBTableField> _list
				= new System.Collections.Generic.List<DBTableField>();

			for (int a = 0; a < this.AttributeCollection.Count; a++) {
				switch (this.AttributeCollection[a].Name) {
					case "attributes":
						#region _list.Add( ... );
						for (int c = 0; c < this.AttributeCollection[a].CompositeCollection.Count; c++) {
							switch (this.AttributeCollection[a].CompositeCollection[c].Type) {
								case "table_attribute":
									_list.Add(_tableField = new DBTableField());
									_tableField.IsIdentity = false;

									for (int aa = 0; aa < this.AttributeCollection[a].CompositeCollection[c].AttributeCollection.Count; aa++) {
										switch (this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Name) {
											case "name":
												_tableField.Name = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", "");
												break;
											case "primary_key":
												_tableField.IsPK
													= this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
												break;
											case "unique":
												_tableField.isUnique
													= this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
												break;
											case "nullable":
												_tableField.IsNullable
													= this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
												break;
											case "comment":
												_tableField.DBDescription = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", "");
												string[] _comment = OGen.Libraries.Utilities.ParameterNameValuePairList_Split(
													//AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", ""),
													_tableField.DBDescription, 
													";",
													":",

													"identity", // ___________ 0
													"length", // _____________ 1
													"sqlserver", // __________ 2
													"psql", // _______________ 3
													"numericPrecision", // ___ 4
													"numericScale", // _______ 5
													"type", // _______________ 6
													"unique" // ______________ 7
												);
												if (!string.IsNullOrEmpty(_comment[0]))
													_tableField.IsIdentity = bool.Parse(_comment[0]);
												if (!string.IsNullOrEmpty(_comment[1]))
													_tableField.Size = int.Parse(_comment[1], System.Globalization.CultureInfo.CurrentCulture);

												// sql server
												if (!string.IsNullOrEmpty(_comment[2]))
													_tableField.SQLServerTypeName = _comment[2];

												// postgresql
												if (!string.IsNullOrEmpty(_comment[3]))
													_tableField.PostgreSQLTypeName = _comment[3];

												if (!string.IsNullOrEmpty(_comment[4]))
													_tableField.Numeric_Precision = int.Parse(_comment[4], System.Globalization.CultureInfo.CurrentCulture);
												if (!string.IsNullOrEmpty(_comment[5]))
													_tableField.Numeric_Scale = int.Parse(_comment[5], System.Globalization.CultureInfo.CurrentCulture);

												break;
											default:
												break;
										}

									}
									break;
							}
						}
						#endregion
						break;
				}
			}

			return _list.ToArray();
		}
Exemple #2
0
        public DBTableField[] TableFields()
        {
            DBTableField _tableField;

            System.Collections.Generic.List <DBTableField> _list
                = new System.Collections.Generic.List <DBTableField>();

            for (int a = 0; a < this.AttributeCollection.Count; a++)
            {
                switch (this.AttributeCollection[a].Name)
                {
                case "attributes":
                    #region _list.Add( ... );
                    for (int c = 0; c < this.AttributeCollection[a].CompositeCollection.Count; c++)
                    {
                        switch (this.AttributeCollection[a].CompositeCollection[c].Type)
                        {
                        case "table_attribute":
                            _list.Add(_tableField  = new DBTableField());
                            _tableField.IsIdentity = false;

                            for (int aa = 0; aa < this.AttributeCollection[a].CompositeCollection[c].AttributeCollection.Count; aa++)
                            {
                                switch (this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Name)
                                {
                                case "name":
                                    _tableField.Name = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", "");
                                    break;

                                case "primary_key":
                                    _tableField.IsPK
                                        = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
                                    break;

                                case "unique":
                                    _tableField.isUnique
                                        = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
                                    break;

                                case "nullable":
                                    _tableField.IsNullable
                                        = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Value;
                                    break;

                                case "comment":
                                    _tableField.DBDescription = this.AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", "");
                                    string[] _comment = OGen.Libraries.Utilities.ParameterNameValuePairList_Split(
                                        //AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String.Replace("#", ""),
                                        _tableField.DBDescription,
                                        ";",
                                        ":",

                                        "identity",                                                             // ___________ 0
                                        "length",                                                               // _____________ 1
                                        "sqlserver",                                                            // __________ 2
                                        "psql",                                                                 // _______________ 3
                                        "numericPrecision",                                                     // ___ 4
                                        "numericScale",                                                         // _______ 5
                                        "type",                                                                 // _______________ 6
                                        "unique"                                                                // ______________ 7
                                        );
                                    if (!string.IsNullOrEmpty(_comment[0]))
                                    {
                                        _tableField.IsIdentity = bool.Parse(_comment[0]);
                                    }
                                    if (!string.IsNullOrEmpty(_comment[1]))
                                    {
                                        _tableField.Size = int.Parse(_comment[1], System.Globalization.CultureInfo.CurrentCulture);
                                    }

                                    // sql server
                                    if (!string.IsNullOrEmpty(_comment[2]))
                                    {
                                        _tableField.SQLServerTypeName = _comment[2];
                                    }

                                    // postgresql
                                    if (!string.IsNullOrEmpty(_comment[3]))
                                    {
                                        _tableField.PostgreSQLTypeName = _comment[3];
                                    }

                                    if (!string.IsNullOrEmpty(_comment[4]))
                                    {
                                        _tableField.Numeric_Precision = int.Parse(_comment[4], System.Globalization.CultureInfo.CurrentCulture);
                                    }
                                    if (!string.IsNullOrEmpty(_comment[5]))
                                    {
                                        _tableField.Numeric_Scale = int.Parse(_comment[5], System.Globalization.CultureInfo.CurrentCulture);
                                    }

                                    break;

                                default:
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    #endregion
                    break;
                }
            }

            return(_list.ToArray());
        }