Prod.: Engine, ver.: 6013, ID: 60000693, Wish : Retrieve version and also custom properties from a vdml vdcl file without opening the file

Wish : Retrieve version and also custom properties from a vdml vdcl file without opening the file

Article60000693
TypeWish
ProductEngine
Version6013
Date Added11/14/2008
FixedYes [11/20/2008]
Submitted byAdam White
Keywords

Subject

Retrieve version and also custom properties from a vdml vdcl file without opening the file

Summary

Can you expose a property/method that will return the version of a vdml or vdcl file. This will allow us to determine if we need to convert the Objects in the standard file across to custom objects on load.

Solution

In version 6014 new static methods was added in vdDocument object.
GetFileProperties and  GetFileActivator
same methods are also added in VectorDraw.Professional.Utilities.GlobalUtilities in order to be called from COM developers using VB6 or Delphi.

GetFileProperties  method reads only the saved vdFileProperties from an existing file.
GetFileActivator method read only the saved VectorDraw.Serialize.Activator from an existing file.The activator will provide all the dlls that were used when the file was saved. This can provide to the user not only the VDF version but also he customer's custom object version that was used.

VB6 Example:
''Create a new VectorDraw_Professional.GlobalUtilities object in order to call some static methods.

Dim utils As New VectorDraw_Professional.GlobalUtilities
'read the vdFileProperties from an existing file.

Dim props As VectorDraw_Professional.vdFileProperties
Set props = utils.GetFileProperties("c:\1.vdml")

'display a property from the object
If Not props Is Nothing Then MsgBox props.Author

'read the VectorDraw_Serialize.Activator object from an existing file.
Dim activator As VectorDraw_Serialize.Activator
Set activator = utils.GetFileActivator("c:\1.vdml")
Dim dlls() As String

'Get the array of string ellements contains the Full Type Name and Version number of the Assemply where the type is implemented.
'for example a string element may be "VectorDraw.Professional.vdCollections.vdSelections, Version=6.1.6014.0"

If Not activator Is Nothing Then
dlls = activator.GetAssemplyTypes
MsgBox dlls(0)
End If

C# Example:

//Create a new VectorDraw.Professional.Utilities.GlobalUtilities object in order to call some static methods.
VectorDraw.Professional.Utilities.GlobalUtilities utils = new VectorDraw.Professional.Utilities.GlobalUtilities();


//'read the vdFileProperties from an existing file.
VectorDraw.Professional.vdObjects.vdFileProperties props = new VectorDraw.Professional.vdObjects.vdFileProperties();
props = utils.GetFileProperties(@"c:\1.vdml");

//'display a property from the object
if (props != null) MessageBox.Show(props.Author.ToString());

//'read the VectorDraw_Serialize.Activator object from an existing file.
VectorDraw.Serialize.Activator activator = new VectorDraw.Serialize.Activator();
activator = utils.GetFileActivator(@"c:\1.vdml");
string[] dlls;

//Get the array of string ellements contains the Full Type Name and Version number of the Assemply where the type is implemented.
//for example a string element may be "VectorDraw.Professional.vdCollections.vdSelections, Version=6.1.6014.0"
if (activator !=null)
{
   dlls=activator.GetAssemplyTypes();
   MessageBox.Show( dlls[0]);
}