/// <summary> /// Serialize the model to a DOT graph notation. /// </summary> /// <returns>A string representing the model serialized in DOT notation.</returns> public string ToDOT() { var relationships = storage.AllInstancesDerivedFromType <IfcRelationship>(); var visited = new List <Guid>(); // Ids of visited nodes; var relations = new StringBuilder(); foreach (var r in relationships) { var rType = r.GetType(); foreach (var p in r.GetType().GetProperties().Where(p => p.DeclaringType == r.GetType())) { var pVal = p.GetValue(r); if (pVal is IList && pVal.GetType().IsGenericType) { var vs = (IList)pVal; foreach (BaseIfc v in vs) { relations.AppendLine($"\t\"{r.Id} : {rType.Name}\" -- \"{v.Id} : {v.GetType().Name}\""); } } else if (pVal is BaseIfc) { var v = (BaseIfc)pVal; relations.AppendLine($"\t\"{r.Id} : {rType.Name}\" -- \"{v.Id} : {v.GetType().Name}\""); } else if (pVal == null) { relations.AppendLine($"\t\"{r.Id} : {rType.Name}\" -- \"null\""); } } } string graph = $@"graph model{{ rankdir=LR node [shape=box]; {relations.ToString()} }}"; return(graph); }