C# Serialization Guide Part 11 – Json.Net

Tuesday, September 16, 2014

,Probably the most popular way to using Json format to/from C# is by Json.Net library This is an great 3party package with great demos and open-source solution, you can download :the full lib from here http://james.newtonking.com/json:   or from codeplex https://json.codeplex.com/ .or directly from visual studio Nuget console Anyway, for read/ write to/from Json format I where show the DataContractJsonSerializer usage :in my former json serialization post http://blogs.microsoft.co.il/uriel99/2014/04/27/c-serialization-guide-part-6-json/ .but using Json.Net Library is very good alternative After you download the files all you need is the proper dll from binary folder for example ,the .Net4.5 version. And add it as reference to you project You can use the service either on local file...
אין תגובות

C# Serialization Guide Part 10 – Linq To Xml

Tuesday, June 24, 2014

Linq To XML is usually not including at the serialization Market. But the simple API will prove that .there is no reason for it :Under System.Xml.Linq you will have a few goodies as ,XDocument that represents the Doc itself ,XElement that represents any element on the tree .Xattribute that represents inner Attribute of any XElement .XDeclaration for haders. .and more. :So our serialization Contract is : public interface ISerializeService { bool write(object data, Type type, string path); object read(string path, Type t); } :And a simple Data to test...
3 תגובות

C# Serialization Guide Part 9 – Encryption

Monday, June 9, 2014

.Encryption of serialized files is important thing ,Using file transportation could expose our data to unauthorized customers Encryption as a subject is out of the scope here , yet we can try encrypt some file using simple .Binary serialization because binary is obviously the simplest way for scrambling ,It is based on binary file with different indexes, again the encryption algorithm is not the issue .so assume you already has an algorithm, or like in my demo a simple SymmetricAlgorithm Back to our demo, in former posts in my serialization series, I used to base the read and write ,on some base serialization Contract .So here it...
אין תגובות

C# Serialization Guide Part 8 – Zip files

Tuesday, May 27, 2014

Writing to an zip file is very easy , this is actually required some algorithm to build the internal file hierarchy, the Zip/Rar file is built from what we called Entries , and those entries are kept like a stack one above each other so our job is to build this stack , also if required we need to extract .the files from it .I am definitely not ganna writing the full demo, only a starter using the new ZipFile API ;ZipFiles usage could be one of two major tasks (or both) .1 .compress to Zip files is a solution for a large scale...
אין תגובות

C# Serialization Guide Part 7 – Known Types

Friday, May 2, 2014

A special attribute that can be added to any serialized object (where using DataContractSerialization) There is a few ways to demonstrate the knownType usage, i myself check out a few examples ..around the net and they where kind of so so ,In my example we will try to put inside a serialized object a referenced member of type Object .meaning not a final implementation .it is relevant when Either you writing a base service or not yet implement the reference object :The code structure may be like that public class MyData { public int PublicID {...
אין תגובות

C# Serialization Guide Part 6 – JSON

Sunday, April 27, 2014

Json is a nice transmission protocol based simple text which is popular especially on web .services , but C# could also serilize for Json format The main benefit of using C# to Json is the javaScript – Ajax built in supported to deserialized .those files :So , lets get back to our serialization contract public interface ISerializeService { bool write(object data, Type type, string path); object read(string path, Type t); } ,And we needs some data object to test pay attention to DataContract and DataMember attributes ...
תגובה אחת

C# Serialization Guide Part 5 – functions

Wednesday, April 23, 2014

In general functions is out of the scope. There is no reason to serialize functions, and if you exist you can serialize text who describe the function logic, we need to remember that the all idea of .seilalization is to transfer data from endpoint to endpoint In WCF we did something close but yet, we are just exposing an public service signature and not the implementation, the reason of this discussion came out since we are try to keep a whole .object on a Text-file and maybe we like to deserialized it as is .For a start lets exam the result of our...
אין תגובות

C# Serialization Guide Part 4 – Binary serializer

Friday, April 18, 2014

..Now, back to the basics, or may we say to the computing Origin ,Of course the base of all stream , networking , and of course a Serialization is Binary .And to Translate an object to the smallest units of bytes If we would try to compare Binary to XML it probably faster to process , so if we talking about .large amount of data just think about binary .The binary encoding is quite unreadable, but don’t trust it as encrypted .Note: The XML could be found very useful to transfer via Web-Services for other platforms :So again define the DTO , the Contract and the...
אין תגובות

C# Serialization Guide Part 3 – ISerializable Interface

Monday, April 14, 2014

Another popular way to use serialization is by customize the serialization environment .But than the serialization results depends on your implementation .This is often more complicated but indeed more flexible :again lets used the base serialization Contract as we saw at former serialization posts public interface ISerializeService { bool write(object data, Type type); object read(string path,Type t); } :Now lets define the object we like to serialize public class SerializeTest : ISerializable { public string...
אין תגובות