Skip to content

Instantly share code, notes, and snippets.

@mgorbach
Created September 28, 2015 15:07
Show Gist options
  • Save mgorbach/e2515ca91d2d1d742e07 to your computer and use it in GitHub Desktop.
Save mgorbach/e2515ca91d2d1d742e07 to your computer and use it in GitHub Desktop.
C# Serialization
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