public override void Assign(object value, IGraphProcessingEnvironment procEnv) { IGraphElement elem = (IGraphElement)DestVar.GetVariableValue(procEnv); object container = elem.GetAttribute(AttributeName); object key = KeyExpression.Evaluate(procEnv); AttributeType attrType = elem.Type.GetAttributeType(AttributeName); BaseGraph.ChangingAttributeAssignElement(procEnv.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(procEnv.Graph, elem, attrType); }
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; } } }