public List <Vertex> ReadFile(FileStream stream) { List <Vertex> vertices = new List <Vertex>(); using (StreamReader reader = new StreamReader(stream)) { string line = reader.ReadLine(); var variables = line.Split(" "); ShortestPathVertex vertex = new ShortestPathVertex() { VertexId = variables[0], }; vertices.Add(vertex); } return(vertices); }
static void Main(string[] args) { //RuntimeTypeModel.Default.Add(typeof(VertexValue), false).SetSurrogate(typeof(VertexValueSurrogate)); RuntimeTypeModel.Default[typeof(Vertex)].AddSubType(455, typeof(ShortestPathVertex)); ShortestPathVertex v = new ShortestPathVertex() { VertexId = "123", Value = Primitive.Create <int>(456), }; byte[] result; using (MemoryStream ms = new MemoryStream()) { Serializer.SerializeWithLengthPrefix <ShortestPathVertex>(ms, v, PrefixStyle.Base128); result = ms.ToArray(); } using (MemoryStream ms = new MemoryStream(result)) { Vertex vOut = Serializer.DeserializeWithLengthPrefix <ShortestPathVertex>(ms, PrefixStyle.Base128); } }