Esempio n. 1
0
        /// <summary>
        /// Gets the cell renderer for given cell type.
        /// </summary>
        /// <returns>The cell handler.</returns>
        /// <param name="cell">Cell to be added.</param>
        /// <param name="isGroup">If <c>true</c>, then group handlers will be included in the lookup as well.</param>
        protected virtual CellRenderer GetCellRenderer(Cell cell, bool isGroup = false)
        {
            Type type  = cell.GetType();
            var  cache = isGroup ? _groupCellRendererCache : _cellRendererCache;

            if (cache.ContainsKey(type))
            {
                var cacheCellRenderer = cache[type];
                cacheCellRenderer.SendCreatedCell(cell, isGroup);
                return(cacheCellRenderer);
            }

            CellRenderer renderer = null;

            renderer = Forms.GetHandler <CellRenderer>(type);

            if (renderer == null)
            {
                Log.Error("Cell type is not handled: {0}", cell.GetType());
                throw new ArgumentException("Unsupported cell type");
            }

            renderer.SetGroupMode(isGroup);
            renderer.SendCreatedCell(cell, isGroup);
            return(cache[type] = renderer);
        }