Created
September 28, 2015 15:07
-
-
Save mgorbach/e2515ca91d2d1d742e07 to your computer and use it in GitHub Desktop.
C# Serialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class DatabaseBlobSerializer : IBlobSerializer | |
{ | |
public byte[] Serialize<T>(T obj) | |
{ | |
if (obj is Color) | |
{ | |
var color = (Color)obj; | |
var bytes = new byte[] { color.R, color.B, color.G, color.A }; | |
return bytes; | |
} | |
else | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public object Deserialize(byte[] data, Type type) | |
{ | |
throw new NotImplementedException(); | |
} | |
public bool CanDeserialize(Type type) | |
{ | |
if (type == typeof(Color)) | |
{ | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment