public static JSONObject Serialize(this IOConnection conn) { var connJs = new JSONObject(JSONObject.Type.OBJECT); connJs.AddField("From", conn.From.GUID); connJs.AddField("Output", conn.Output.Name); connJs.AddField("To", conn.To.GUID); connJs.AddField("Input", conn.Input.Name); return(connJs); }
private int CompareConnectionPriority(IOConnection a, IOConnection b) { int priorityA = _connectionPriorities[a]; int priorityB = _connectionPriorities[b]; if (priorityA < priorityB) { return(-1); } else if (priorityA > priorityB) { return(1); } else { return(0); } }
private int GetPriority(IOConnection conn) { if (_connectionPriorities.ContainsKey(conn)) { return(_connectionPriorities[conn]); } else { var priority = 0; foreach (var input in conn.From.Inputs) { IOConnection[] conns = ConnectionsTo(conn.From, input); foreach (var prior in conns) { priority++; priority += GetPriority(prior); } } _connectionPriorities.Add(conn, priority); return(priority); } }
public void MoveConnection(IOConnection conn, int newIndex) { Connections.Remove(conn); Connections.Insert(newIndex, conn); CommitChanges(); }
public void Disconnect(IOConnection conn) { Connections.Remove(conn); CommitChanges(); }