public Uri plusQuery(Map q) { if (q == null || q.isEmpty()) return this; Map merge = m_query.dup().setAll(q); StringBuilder s = new StringBuilder(256); IDictionaryEnumerator en = merge.pairsIterator(); while (en.MoveNext()) { if (s.Length > 0) s.Append('&'); string key = (string)en.Key; string val = (string)en.Value; appendQueryStr(s, key); s.Append('='); appendQueryStr(s, val); } Sections t = new Sections(); t.scheme = m_scheme; t.userInfo = m_userInfo; t.host = m_host; t.port = m_port; t.frag = m_frag; t.pathStr = m_pathStr; t.path = m_path; t.query = merge.ro(); t.queryStr = s.ToString(); return new Uri(t); }
////////////////////////////////////////////////////////////////////////// // Map ////////////////////////////////////////////////////////////////////////// public void writeMap(Map map) { // get k,v type MapType t = (MapType)map.@typeof(); // decide if we're going output as single or multi-line format bool nl = isMultiLine(t.m_k) || isMultiLine(t.m_v); // figure out if we can use an inferred type bool inferred = false; if (curFieldType != null && curFieldType.fits(Sys.MapType)) { inferred = true; } // clear field type, so it doesn't get used for inference again curFieldType = null; // if we don't have an inferred type, then prefix of type if (!inferred) wType(t); // handle empty map if (map.isEmpty()) { w("[:]"); return; } // items level++; w('['); bool first = true; IDictionaryEnumerator en = map.pairsIterator(); while (en.MoveNext()) { if (first) first = false; else w(','); if (nl) w('\n').wIndent(); object key = en.Key; object val = en.Value; writeObj(key); w(':'); writeObj(val); } w(']'); level--; }