vb.net - FileHelpers Library - Append Multiple Records on Transform -


using filehelpers library great things in vb.net. parsing files dynamic classes built text file templates. 1 thing can't find: way read in single record , determine should result in generation of 2 records.
current code:

dim fromtype type = dynamic.classbuilder.classfromsourcefile(myfilepath, mydynamictypename, netlanguage.vbnet)

dim fromrecords() object fromrecords = filehelpers.commonengine.readstring(fromtype, mystringbuilder.tostring)

'... maybe code here check values

dim engine new filetransformengine(of itransformable(of mydestinationclass), mydestinationclass)

' ideally in next line see conditions , able generate 2 records single source line. dim payrecords() object = engine.transformrecords(fromrecords)

alternately, if there way implement "itransformable(of ..." transformto() , have return multiple records, put logic in dynamic class definition transformto() method.

thoughts?

here sample of source dynamic class:

imports filehelpers ' never forget

_ public notinheritable class mydynamicclass implements itransformable(of mydestinationclass) _ public name string

<fieldquoted(""""c, quotemode.optionalforread, multilinemode.allowforread)> _ public keytype string  public hours double 

public function transformto() mydestinationclass implements itransformable(of mydestinationclass).transformto dim res new mydestinationclass

    res.contactname = name     ' here say... instead of return res     if keytype="abcd"         dim newres new mydestinationclass         newres.contactname = name + " 2nd contact"          dim resarray() mydestinationclass         redim resarray(1)         resarray(0) = res         resarray(1) = newres     end if     return resarray     ' or alternately refer engine, not in scope dynamic record (is it?). like...     engine.appendtodestination(new mydestinationclass(...)) 

end function end class

i think main problem you're going run itransformable.transformto() spec'ed return single t value.

this called in loop when call engine.transformrecords(), 1 output record added each input record.

i don't think big change if didn't mind doing own version of filetransformengine, don't see clean way as-is.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -