private static string ToString(ITransientObject value, IGraph graph, bool firstLevelObjectEmitted, IDictionary <string, IObject> nameToObject, IGraphProcessingEnvironment procEnv) { StringBuilder sb = new StringBuilder(); string transientObjectType = value.Type.PackagePrefixedName; sb.Append(transientObjectType); if (procEnv != null || !firstLevelObjectEmitted) { sb.Append("{"); } bool first = true; if (procEnv != null) { sb.Append("&:" + procEnv.GetUniqueId(value)); first = false; } if (!firstLevelObjectEmitted) { foreach (AttributeType attrType in value.Type.AttributeTypes) { if (first) { first = false; } else { sb.Append(","); } sb.Append(attrType.Name); sb.Append(":"); sb.Append(EmitHelper.ToStringAutomatic(value.GetAttribute(attrType.Name), graph, true, nameToObject, procEnv)); } } if (procEnv != null || !firstLevelObjectEmitted) { sb.Append("}"); } return(sb.ToString()); }
public static void AssignAttributeIndexed(object target, object key, object value, string attributeName, IGraph graph) { if (target is IGraphElement) { IGraphElement elem = (IGraphElement)target; object container = elem.GetAttribute(attributeName); AttributeType attrType = elem.Type.GetAttributeType(attributeName); BaseGraph.ChangingAttributeAssignElement(graph, elem, attrType, value, key); if (container is IList) { IList array = (IList)container; array[(int)key] = value; } else if (container is IDeque) { IDeque deque = (IDeque)container; deque[(int)key] = value; } else { IDictionary map = (IDictionary)container; map[key] = value; } BaseGraph.ChangedAttribute(graph, elem, attrType); } else if (target is IObject) { IObject elem = (IObject)target; object container = elem.GetAttribute(attributeName); AttributeType attrType = elem.Type.GetAttributeType(attributeName); if (container is IList) { IList array = (IList)container; array[(int)key] = value; } else if (container is IDeque) { IDeque deque = (IDeque)container; deque[(int)key] = value; } else { IDictionary map = (IDictionary)container; map[key] = value; } } else { ITransientObject elem = (ITransientObject)target; object container = elem.GetAttribute(attributeName); AttributeType attrType = elem.Type.GetAttributeType(attributeName); if (container is IList) { IList array = (IList)container; array[(int)key] = value; } else if (container is IDeque) { IDeque deque = (IDeque)container; deque[(int)key] = value; } else { IDictionary map = (IDictionary)container; map[key] = value; } } }