The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Custom serialization

Last post 02-14-2008, 6:48 AM by paschoal1. 11 replies.
Sort Posts: Previous Next
  •  02-11-2008, 9:28 AM 8001

    Custom serialization

    Is it possible to serialize a collection in the structure below?

    Obs: each record is defined in the position (1, 2...). Each column is defined as an entry data.

    My problem is that I have to work with a partner that expects to receive this scructure...

    Code:
    <viewentries toplevelentries="7">
    	<viewentry position="1">
    		<entrydata columnnumber="0">
    			<text>Bla bla bla</text>
    		</entrydata>
    
    		<entrydata columnnumber="1" name="Descricao">
    			<text>asdasd</text>
    		</entrydata>
    
    		<entrydata columnnumber="2" name="$6">
    			<text>Nao aceita</text>
    		</entrydata>
    
    		<entrydata columnnumber="3" name="DT_ELABORACAO">
    			<datetime dst="true">20080123T180434,41-02</datetime>
    		</entrydata>
    
    		<entrydata columnnumber="4" name="$8">
    			<text>Tecnologia</text>
    		</entrydata>
    	</viewentry>
    
    	<viewentry position="2">
    		<entrydata columnnumber="0" name="$4">
    			<text>Bla bla bla 2</text>
    		</entrydata>
    		<entrydata columnnumber="1" name="Descricao">
    			<text>Esta eh a descricao</text>
    		</entrydata>
    
    		<entrydata columnnumber="2" name="$6">
    			<text>Outro texto</text>
    		</entrydata>
    
    		<entrydata columnnumber="3" name="DT_ELABORACAO">
    			<datetime dst="true">20080122T174232,93-02</datetime>
    		</entrydata>
    
    		<entrydata columnnumber="4" name="$8">
    			<text>Tecnologia</text>
    		</entrydata>
    	</viewentry>
    </viewentries>

     

  •  02-12-2008, 2:09 AM 8014 in reply to 8001

    Re: Custom serialization

    If its needed to write some C# code to work around this serialization, its no problem, I can do that. I would just like some tips on how I can do that using an ES collection (or an entity) right after it is loaded.

    Any help will be highly appreciated.

    Thanks very much! 

     

  •  02-12-2008, 3:34 AM 8015 in reply to 8014

    Re: Custom serialization

  •  02-12-2008, 3:39 AM 8016 in reply to 8015

    Re: Custom serialization

    Well quimbo, you redirected me to the forums....I didnt find there any anwers to my issue....

    :(

  •  02-12-2008, 4:01 AM 8017 in reply to 8016

    Re: Custom serialization

    Hi Paschoal

    The link quimbo put in just wasn't formatted properly - if you copied and pasted it into the browser it works fine and points to a couple of serialization helpers that TrevorW posted.  Here's the (hopefully) correcly coded link: http://community.entityspaces.net/forums/thread/7332.aspx

  •  02-12-2008, 4:06 AM 8019 in reply to 8017

    Re: Custom serialization

    Thanks to both!

    I will definitely take a look at it!

  •  02-12-2008, 4:50 AM 8022 in reply to 8017

    Re: Custom serialization

    Well I might be wrong, but as far as I understood those methods were very similar to the methods in the XMLSerializer class of .net framework. In that sense, I dont think they are meant to create a custom structure as I posted above...the XML created follows the default structure, with only the field (attribute) names and its contents...

    Does it make sense?

  •  02-13-2008, 7:39 AM 8051 in reply to 8022

    Re: Custom serialization

    Hi Paschoal

    I must admit I've not had any need to play with serialization like that but a couple of potential helpers for you:

    1) Maybe take a look at whether you can customise the output of the proxystubs that you can generate

    2) The following articles on CodeProject might help you with implementing a custom serialization method (by the looks of things you have to implement the ISerializable interface which requires you to implement 2 methods - I'll let you read about that in the articles:

    http://www.codeproject.com/KB/XML/XMLFormatter.aspx

    http://www.codeproject.com/KB/cs/SerializeUtility.aspx

    Hope those help

    Cheers

    Martin

  •  02-14-2008, 4:22 AM 8067 in reply to 8051

    Re: Custom serialization

    Can I use Pure WCF Client Side Proxies as described here to achieve this goal? or am I totally wrong about it.

    http://www.entityspaces.net/blog/CategoryView,category,WCF.aspx#a5ed2f833-3cdd-4142-b3d2-9bdb67d0d2d4

    If so, how?

    thanks

  •  02-14-2008, 4:45 AM 8068 in reply to 8067

    Re: Custom serialization

    Not sure to be honest Paschoal - as I say, I've not had to tinker with Serialization so I don't have personal experience there - I only mentioned it as I remembered it being mentioned elsewhere in the forums and assumed that the EntitySpaces code was implementing some sort of custom serialization when using the proxies (as it doesn't always output everything - i.e. dirty columns only, entity state if needed etc).

    I suppose it depends on where (and if) this customised serialization is taking place - if it's in generated code then you can naturally override/alter that, if it's in the base classes though then that's obviously different.

    Hopefully one of the ES guys will chip in to confirm.

    Just in case the code isn't accessible though you may want to take a look at the two articles I've pointed to (if you haven't already) as implementing your own custom serialization methods doesn't look too complex.

    Hope that helps - at least until one of the ES guys answers anyway

    Thanks

    Martin

  •  02-14-2008, 5:32 AM 8069 in reply to 8067

    Re: Custom serialization

    Actually Paschoal, the more I look at this, the more I think you'll need to write your own method for generating the XML in the format you need. 

    If you just implement your own custom serialization method (using the ISerializable interface) then it's really just affecting the way that the contents of the object get serialized (i.e. what properties etc) whereas what you want to do (if I understand) is to alter how the collection and start/end "tags" for each entity are output. 

    If the WCF (or other) proxy code that gets generated includes some sort of XML writing elements (rather than just using the standard serialization methods) then you might be able to alter them to suit your needs, I suspect that they use the standard stuff though so you might just want to write your own code to output the XML in the format you need.

    Cheers

    Martin

  •  02-14-2008, 6:48 AM 8071 in reply to 8069

    Re: Custom serialization

    Thanks for your help.
View as RSS news feed in XML