GithubHelp home page GithubHelp logo

lulzzz / shuttle.core.serialization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shuttle/shuttle.core.serialization

0.0 2.0 0.0 33 KB

Serialization adapter.

License: BSD 3-Clause "New" or "Revised" License

C# 100.00%

shuttle.core.serialization's Introduction

Shuttle.Core.Serialization

PM> Install-Package Shuttle.Core.Serialization

An implementation of the ISerializer interface is used to serialize objects into a Stream.

The DefaultSerializer makes use of the standard .NET xml serialization functionality.

Methods

Serialize

Stream Serialize(object message);

Returns the message object as a Stream.

Deserialize

object Deserialize(Type type, Stream stream);

Deserializes the Stream into an obejct of the given type.

ISerializerRootType

The ISerializerRootType interface is an optional interface that serializer implementations can use that allows the developer to specify explicit object types contained within a root type.

The DefaultSerializer implements this interface and it is recommended that you explicitly register types with the same name, but in different namespaes, that will be serialized within the same root type to avoid any conflicts later down the line.

For instance, the following two types will cause issues when used in the root Complex type as they both serialize to the same name and the .Net serializer cannot seem to distinguish the difference:

namespace Serializer.v1
{
	public class MovedEvent
	{
		public string Where { get; set; } 
	}
}

namespace Serializer.v2
{
	public class MovedEvent
	{
		public string Where { get; set; } 
	}
}

namespace Serializer
{
	public class Complex
	{
		public v1.MovedEvent { get; set; }
		public v2.MovedEvent { get; set; }
	}
}

By explicitly specifying the types the DefaultSerializer will add a namespace that will cause the types to be correctly identified.

AddSerializerType

void AddSerializerType(Type root, Type contained);

Specify the contained tpe that is used within te root type somewhere.

shuttle.core.serialization's People

Contributors

eben-roux avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.