public SerializableHierarchy(TypeHierarchy typeHierarchy) { for (int i = 0; i < typeHierarchy._typeDictionary.Count; i++) { types.Add(typeHierarchy._typeDictionary.Get(i)); outgoingEdges.Add(new HashSet <int>(typeHierarchy._typeParents.Values(i))); } }
public static TypeHierarchy Load(string filename) { using (var fileStream = File.OpenRead(filename)) using (var gzipStream = new GZipStream(fileStream, CompressionMode.Decompress)) using (var textStream = new StreamReader(gzipStream)) { var serializer = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore }; var deserializedHier = (SerializableHierarchy)serializer.Deserialize(textStream, typeof(SerializableHierarchy)); var typeHierarchy = new TypeHierarchy(); for (int i = 0; i < deserializedHier.types.Count; i++) { var rId = typeHierarchy._typeDictionary.Get(deserializedHier.types[i], addIfNotPresent: true); Debug.Assert(rId == i); typeHierarchy._typeParents.AddMany(i, deserializedHier.outgoingEdges[i]); } return(typeHierarchy); } }