Click here to Skip to main content
15,893,487 members
Articles / Programming Languages / C#

A Fast/Compact Serialization Framework

Rate me:
Please Sign up or sign in to vote.
4.85/5 (37 votes)
13 Oct 2010GPL35 min read 283.5K   1.2K   175  
A framework for object serializiation/deserialization that is many times faster and yields a compact output.
/*

OpenNxSerialization Framework
Copyright (C) 2006 - 2007 "NeXtreme Innovations"
[The Next Xtreme in ingenuity]

This program is free software, distributed under the terms of
the GNU General Public License Version 2. See the License file
at the top of the source tree.

*/
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;

using NeXtreme.OpenNxSerialization;
using NeXtreme.OpenNxSerialization.IO;
using NeXtreme.OpenNxSerialization.Surrogates;

namespace NeXtreme.CommonTypes
{
    /*       How to use an INxSerializable        */

    /// <summary>
    /// Demomstrates a custom type that implements <see cref="INxSerializable"/>.
    /// </summary>
    [Serializable]
    public class SampleINxSerializableClass : INxSerializable
    {
        public const short FIXED_ID = 0xFee;

        private string id;
        private SampleInternalType nested = new SampleInternalType();
        private Hashtable table = new Hashtable(11);

        /// <summary> Default constructor is not mandatory for types that implement INxSerializable.</summary>
        public SampleINxSerializableClass() { }

        public SampleINxSerializableClass(String title)
        {
            id = title;
            table[1] = new SampleInternalType();
            table[2] = new SampleInternalType();
            table[3] = new SampleInternalType();
            table[4] = new SampleInternalType();
        }

        /// <summary>
        /// Implementation of INxSerializable.Serialize
        /// </summary>
        void INxSerializable.Serialize(INxBinaryWriter w)
        {
            w.WriteObject(id);
            w.WriteObject(nested);
            w.WriteObject(table);
        }

        /// <summary>
        /// Implementation of INxSerializable.Deserialize
        /// </summary>
        void INxSerializable.Deserialize(INxBinaryReader r)
        {
            id = (String)r.ReadObject();
            nested = (SampleInternalType)r.ReadObject();
            table = (Hashtable)r.ReadObject();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect
Pakistan Pakistan
Let a = b ....... (1)
a - b = a - b
a^2 - ab = a^2 - ab
a^2 - ab = a^2 - b^2 (from 1)
a (a - b) = (a + b) (a - b)
a = (a + b) ...... (2)

if a = 1
1 = (1 + 1) (from 1 & 2)
1 = 2 !!

Comments and Discussions