/// <summary> /// Returns a string representation of the given dictionary /// </summary> /// <param name="setmap">The dictionary of which to get the string representation</param> /// <param name="type">The type as string, e.g set<int> or map<string,boolean> </param> /// <param name="content">The content as string, e.g. { 42, 43 } or { "foo"->true, "bar"->false } </param> /// <param name="attrType">The attribute type of the dictionary if available, otherwise null</param> /// <param name="graph">The graph with the model and the element names if available, otherwise null</param> /// <param name="firstLevelObjectEmitted">Prevents emitting of further objects and thus infinite regressions</param> /// <param name="nameToObject">If not null, the names of visited objects are added</param> /// <param name="procEnv">If not null, the processing environment is used for transient object unique id emitting and fetching</param> public static void ToString(IDictionary setmap, out string type, out string content, AttributeType attrType, IGraph graph, bool firstLevelObjectEmitted, IDictionary <string, IObject> nameToObject, IGraphProcessingEnvironment procEnv) { Type keyType; Type valueType; ContainerHelper.GetDictionaryTypes(setmap, out keyType, out valueType); StringBuilder sb = new StringBuilder(256); sb.Append("{"); AttributeType attrValueType = attrType != null ? attrType.ValueType : null; AttributeType attrKeyType = attrType != null ? attrType.KeyType : null; if (setmap != null) { if (valueType == typeof(SetValueType)) { type = "set<" + keyType.Name + ">"; AppendSet(sb, setmap, attrValueType, graph, firstLevelObjectEmitted, nameToObject, procEnv); } else { type = "map<" + keyType.Name + "," + valueType.Name + ">"; AppendMap(sb, setmap, attrKeyType, attrValueType, graph, firstLevelObjectEmitted, nameToObject, procEnv); } } else { type = "<INVALID>"; } sb.Append("}"); content = sb.ToString(); }