// Register a new HGridFormat public void register(HGridFormat format) { lock (m_syncLock) { m_registry.Add(format.Mime, format); } }
/** * Find the HGridFormat for the given mime type. The mime type * may contain parameters in which case they are automatically stripped * for lookup. Throw a RuntimeException or return null based on * checked flag if the mime type is not registered to a format. */ // In Java this was static but that is illegal to access instance members public HGridFormat find(string mime, bool bChecked) { // normalize mime type to strip parameters int semicolon = mime.IndexOf(';'); if (semicolon > 0) { mime = mime.Substring(0, semicolon).Trim(); } // lookup format HGridFormat format = null; lock (m_syncLock) { format = m_registry[mime]; } if (format != null) { return(format); } else { if (bChecked) { throw new Exception("No format for mime type: " + mime); } return(null); } }
// List all registered formats public HGridFormat[] list() { HGridFormat[] acc = null; lock (m_syncLock) { acc = new HGridFormat[m_registry.Count]; m_registry.Values.CopyTo(acc, 0); } return(acc); }