This tutorial show how to Initialize Serializer for use
Create Compiler Info:-
Dim s As New CompilerInfo 'Create Compiler Info Instance
Now you need to Provide Type Providers which tell compiler how to read/write object of specific type. There are built in type providers in StateScript Class Library. In v3.2 These are:-
- BooleanTypeProvider : Provides how to read/write Boolean variables
- ValueTypesProvider : Provides How to read/write Value Types
- StringTypeProvider : Provides string to be encoded to base64 and from base64
- CollectionTypesProvider : Every type implementing collection will be compiled with it
- ObjectTypeProvider : Highly extendible provider which provides compiling any other type
You can add all providers as:-
'Add Providers which serialize specified types
s.AddProviders({New BooleanTypeProvider,
New ValueTypesProvider,
New StringTypeProvider,
New CollectionTypesProvider,
New ObjectTypeProvider})
You must Take care of arrangement of adding provider
But Why?
Compiler gets provider which was provided 1st and checks weather object was implemented / inherited from that type or is of that type
Let you provide ObjectTypeProvider before any other type provider then all types will be serialized according to object type provider as everything is inherited from object
Customizing Compiler Info Is Very Simple:-
s.Collection = "&" 'The Char to separate collection items from each other
s.EndBlock = "}" 'The Char to identify the end of a block
s.StartBlock = "{" 'The Char to Identify the start of a block
s.VariableName = "." 'The char after which variable(field) Name is written
s.VariableValue = "=" 'The Char after which value of variable(field) is written