Alright, this is still unfinished, At the moment it only supports MYSQL, but I will finish rest later, if I get time. It's untested so far and so, but looks like it would work.
Anyways, when I get home I will test it and fix whatever I find of bugs etc.
It also still contains the xml converter as it's under solution.
The XmlLib is a DLL, which you just add as reference to your project, however there is some major things you need to do, before you actually use it.
First of all you have to initialize the dbconfig.
The extension of all xml files using this library should be ".db.xml" as well.
Config.db.xml example
Now that the config has been created you have to initialize it.
Now that the config is initialized, then you will need to intialize the different database structures. A good idea would be to do a dictionary with the tablename as key and the database structure as value.
To Initialize a dbstruct you call Read().
An example on how a dbstruct could be initialized.
There is an example in the debug folder called example.db.xml.
It looks like following:
Note: datasize is only available for strings.
The Get() will get a XmlDbList out of the database, which is the dblist containing all values you want to insert/update/read. You have to update the XmlDbList, whenver you want to, but only call Get() on load and Insert()/Fill() on logout or whenever you want to save.
Insert() will insert a new column to the table, out of a XmlDbList.
Fill() will fill (update) a column to the table, out of a XmlDbList.
Library Members
AlreadyReadDbException: <Class>
ConfigLoad: <Enum>
DataType: <Enum>
DBLanguage: <Enum>
DBValue: <Struct>
EmptyDbStructException: <Class>
InvalidColumnException: <Class>
InvalidDbFileException: <Class>
XmlDbConfig: <Class>
XmlDbList: <Class>
XmlDbStruct: <Class>
I think that's it at the moment.
Download: (Includes the whole solution! ini to xml converter & the xml library)
[Only registered and activated users can see links. Click Here To Register...]
Enjoy :).
Anyways, when I get home I will test it and fix whatever I find of bugs etc.
It also still contains the xml converter as it's under solution.
The XmlLib is a DLL, which you just add as reference to your project, however there is some major things you need to do, before you actually use it.
First of all you have to initialize the dbconfig.
The extension of all xml files using this library should be ".db.xml" as well.
Config.db.xml example
Code:
<?xml version="1.0" encoding="utf-8" ?> <dbconfig> <dblanguage>MYSQL</dblanguage> <dbconnectionstring>HOST;USER;PASS;DATABASE</dbconnectionstring> </dbconfig>
Code:
XmlDbConfig.Initialize();//This will initialize the config. XmlDbConfig.InitializeDbConnection();//This will initialize the database connection.
Code:
Dictionary<string, XmlDbStruct> DatabaseStructures;//The collection of the database structures.
An example on how a dbstruct could be initialized.
Code:
XmlDbStruct strct = new XmlDbStruct();//Initializing the xmldbstruct.
strct.Read("accounts.db.xml");//Reading the database structure.
DatabaseStructures.Add("Accounts", strct);//Adding the structure to the dictionary.
It looks like following:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Accounts Primarykey="UID">
<UID datatype="UInt32">
1000000
</UID>
<AccountName datatype="String" datasize="16">
Error
</AccountName>
<Password datatype="String">
1234
</Password>
</Accounts>
The Get() will get a XmlDbList out of the database, which is the dblist containing all values you want to insert/update/read. You have to update the XmlDbList, whenver you want to, but only call Get() on load and Insert()/Fill() on logout or whenever you want to save.
Insert() will insert a new column to the table, out of a XmlDbList.
Fill() will fill (update) a column to the table, out of a XmlDbList.
Library Members
AlreadyReadDbException: <Class>
Code:
AlreadyReadDbException();
Code:
None, DatabaseLanguage, ConnectionString
Code:
Char, String, SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, UInt64, Double, Float, Boolean
Code:
MYSQL, MSSQL
Code:
DataType dataType; object Value;
Code:
EmptyDbStructException();
Code:
InvalidColumnException(string column);
Code:
InvalidDbFileException();
Code:
Initialize(string configfile); InitializeDbConnection(); DBLanguage DBLanguage; string ConnectString;
Code:
XmlDbList(object PrimaryKey); string PrimaryKey; void AddOrUpdate(string column, object value); KeyValuePair<string, object>[] GetDbStruct();
Code:
XmlDbStruct(); string TableName; void Read(string DbFile); void Fill(XmlDbList dblist); void Insert(XmlDbList dblist); XmlDbList Get(object PrimaryKey);
Download: (Includes the whole solution! ini to xml converter & the xml library)
[Only registered and activated users can see links. Click Here To Register...]
Enjoy :).