public IGate AddGate(IGate g) { if (g.Type.IsFixed()) { return(g); } else { var key = g.CacheKey; // try to find, including parents IGate r = Lookup(key); if (null == r) { // add to cache var gateid = "#" + _seed++; g.Freeze(gateid); _map[key] = r = g; _list.Add(r); } return(r); } }