/// <summary> /// Set connection /// </summary> /// <param name="c">Key code</param> /// <param name="newconnection">Connection</param> public void SetConnect(int c, Connect newconnection) { if (_connect.ContainsKey(c)) { throw new Exception("Key " + string.Join(",", KeyCodeHelper.SplitKeys(c)) + " is duplicated."); } _connect.Add(c, newconnection); }
/// <summary> /// Return string representation /// </summary> /// <param name="automaton"></param> /// <returns></returns> public static string Dump() { StringBuilder builder = new StringBuilder(); foreach (var instance in _instances) { builder.Append("{ "); builder.Append(instance.Key); builder.Append(" : {"); foreach (var connect in instance.Value.GetConnect()) { builder.Append(" { "); builder.AppendFormat(" ch : {0},", string.Join(",", KeyCodeHelper.SplitKeys(connect.Key))); builder.AppendFormat(" to : {0},", connect.Value.Automaton.ID); builder.AppendFormat(" st : {0} ", connect.Value.Character); builder.Append("} "); } builder.Append("} "); builder.Append("}"); builder.AppendLine(); } return(builder.ToString()); }