Mark0's Forum

Software => TrID File Identifier => Topic started by: JeffB on December 17, 2015, 07:58:33 PM

Title: TrIDEngine.dll definitions
Post by: JeffB on December 17, 2015, 07:58:33 PM
Is it possible to use a single TrIDDefs.TRD package rather than a folder containing individual xml def files when calling the the TrIDEngine.dll ?

Thank you.
Title: Re: TrIDEngine.dll definitions
Post by: Mark0 on December 17, 2015, 09:39:19 PM
The TRD format itself isn't supported, but you surely don't have to load all the individuals XML defs every time.
TrIDEngine provide functions to load single *.trid.xml definitions, one by one, and to get/set the object that represent them all at once.
So it's  possible to package them in any kind of container you may choose.

Here's a very simple example from TrIDEngine's How-to, using serialization.

A possible way to save the definitions:

MyDefBlock = Ctype(PE.GetDefs, System.Collections.ArrayList)
Dim saveFile As FileStream
saveFile = File.OpenWrite(sBasePath & sDefPackageName)
Dim formatter As BinaryFormatter = New BinaryFormatter()
formatter.Serialize(saveFile, MyDefBlock)
saveFile.Close()


Then, for reloading them:

Dim readFile As FileStream
readFile = File.OpenRead(sBasePath & sDefPackageName)
Dim Formatter As BinaryFormatter =  New BinaryFormatter()
MyDefBlock = CType(Formatter.Deserialize(readFile), System.Collections.ArrayList)
readFile.Close()
PE.SetDefs(MyDefBlock)

Hope this helps,
Bye!