[Quantproject-developers] QuantProject/b2_DataAccess DataBaseVersionManager.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: <gla...@us...> - 2004-01-03 16:20:41
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess
In directory sc8-pr-cvs1:/tmp/cvs-serv32120/b2_DataAccess
Modified Files:
DataBaseVersionManager.cs
Log Message:
Minor readability improvements have been
performed: private methods have been grouped
using a region for each public method.
Index: DataBaseVersionManager.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBaseVersionManager.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DataBaseVersionManager.cs 1 Jan 2004 19:07:12 -0000 1.1
--- DataBaseVersionManager.cs 3 Jan 2004 16:20:37 -0000 1.2
***************
*** 55,58 ****
--- 55,75 ----
private SortedList updatingMethods;
+ #region "DataBaseVersionManager"
+ /// <summary>
+ /// The method initialize a populate updatingMethods, a SortedList
+ /// that contains all the delegates that encapsulate all methods
+ /// whose function is to modify the structure of the database.
+ /// The key in the sortedList is the new version number that signs
+ /// the database after the execution of the encapsulated method
+ /// </summary>
+ private void initialize_updatingMethods()
+ {
+ this.updatingMethods = new SortedList();
+ //After adding a new private method to the class, write
+ //the following code, paying attention to the version number:
+ //this.updatingMethods.Add(yourVersionNumber,
+ // new updatingMethodHandler(this.yourMethodName))
+
+ }
public DataBaseVersionManager(OleDbConnection oleDbConnection)
{
***************
*** 77,80 ****
--- 94,126 ----
}
+ #endregion
+ #region "UpdateDataBaseStructure"
+ private int getDataBaseVersionNumber()
+ {
+ this.dataTable_version.Clear();
+ this.oleDbDataAdapter.Fill(this.dataTable_version);
+ DataRow dataRow = this.dataTable_version.Rows[0];
+ return (int)dataRow["veId"];
+ }
+ private void setNewDataBaseVersionNumber(int newVersionNumber)
+ {
+ this.dataTable_version.Rows[0]["veId"] = newVersionNumber;
+ this.oleDbDataAdapter.Update(this.dataTable_version);
+ this.dataTable_version.AcceptChanges();
+ }
+ private void executeMethod(DictionaryEntry itemContainingMethod)
+ {
+ this.databaseVersion = this.getDataBaseVersionNumber();
+ int differenceBetweenNewVersionAndDataBaseVersion =
+ (int)itemContainingMethod.Key - this.databaseVersion;
+ if(differenceBetweenNewVersionAndDataBaseVersion == 1)
+ //db's structure can be updated by the method contained in the item
+ {
+ updatingMethodHandler handler = (updatingMethodHandler)itemContainingMethod.Value;
+ handler();
+ //it calls the method that modifies the db structure
+ this.setNewDataBaseVersionNumber((int)itemContainingMethod.Key);
+ }
+ }
public void UpdateDataBaseStructure()
{
***************
*** 92,147 ****
this.oleDbConnection.Close();
}
-
- }
-
- private int getDataBaseVersionNumber()
- {
- this.dataTable_version.Clear();
- this.oleDbDataAdapter.Fill(this.dataTable_version);
- DataRow dataRow = this.dataTable_version.Rows[0];
- return (int)dataRow["veId"];
- }
-
-
- private void setNewDataBaseVersionNumber(int newVersionNumber)
- {
- this.dataTable_version.Rows[0]["veId"] = newVersionNumber;
- this.oleDbDataAdapter.Update(this.dataTable_version);
- this.dataTable_version.AcceptChanges();
- }
- /// <summary>
- /// The method initialize a populate updatingMethods, a SortedList
- /// that contains all the delegates that encapsulate all methods
- /// whose function is to modify the structure of the database.
- /// The key in the sortedList is the new version number that signs
- /// the database after the execution of the encapsulated method
- /// </summary>
- private void initialize_updatingMethods()
- {
- this.updatingMethods = new SortedList();
- //After adding a new private method to the class, write
- //the following code, paying attention to the version number:
- //this.updatingMethods.Add(yourVersionNumber,
- // new updatingMethodHandler(this.yourMethodName))
-
- }
-
- private void executeMethod(DictionaryEntry itemContainingMethod)
- {
- this.databaseVersion = this.getDataBaseVersionNumber();
- int differenceBetweenNewVersionAndDataBaseVersion =
- (int)itemContainingMethod.Key - this.databaseVersion;
- if(differenceBetweenNewVersionAndDataBaseVersion == 1)
- //db's structure can be updated by the method contained in the item
- {
- updatingMethodHandler handler = (updatingMethodHandler)itemContainingMethod.Value;
- handler();
- //it calls the method that modifies the db structure
- this.setNewDataBaseVersionNumber((int)itemContainingMethod.Key);
- }
-
}
!
!
}
}
--- 138,143 ----
this.oleDbConnection.Close();
}
}
! #endregion
}
}
|