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)

Enjoy






