/// <summary>
        /// Retrieves configuration for specified plugin
        /// </summary>
        /// <typeparam name="TConfig">Plugin configuration type</typeparam>
        /// <param name="conf">Table JSON configuration</param>
        /// <param name="pluginId">Plugin ID</param>
        /// <param name="placement">Plugin placement</param>
        /// <returns></returns>
        public static TConfig GetPluginConfig <TConfig>(this TableConfiguration conf, string pluginId, string placement = null) where TConfig : class
        {
            var config = conf.GetPluginConfiguration(pluginId, placement);

            if (config == null)
            {
                return(null);
            }
            return((TConfig)config.Configuration);
        }
        private static PluginConfiguration GetPluginConfiguration(this TableConfiguration conf, string pluginId, string placement = null)
        {
            var plugins = conf.PluginsConfiguration.Where(
                c => c.PluginId == pluginId && (string.IsNullOrEmpty(placement) || c.Placement == placement)).ToArray();

            if (plugins.Length > 1)
            {
                throw new Exception(string.Format("It is unclear which {0} plugin is mentioned for configuration. You have {1}: at {2}. Please specify placement if you try to update any specific plugin instance. Otherwise please update instances separately."
                                                  , pluginId, plugins.Length, string.Join(", ", plugins.Select(c => c.Placement).ToArray())));
            }

            return(plugins.Length == 0 ? null : plugins[0]);
        }
        /// <summary>
        /// Replaces plugin configuration with whole new configuration
        /// </summary>
        /// <param name="conf">Table configuration</param>
        /// <param name="pluginId">Plugin ID</param>
        /// <param name="pluginConfig">Configuration object</param>
        /// <param name="placement">Plugin placement</param>
        /// <param name="order">Order among particular placement</param>
        public static void ReplacePluginConfig(this TableConfiguration conf, string pluginId, object pluginConfig, string placement = null, int order = 0)
        {
            var config = conf.GetPluginConfiguration(pluginId, placement);

            if (config == null)
            {
                config = new PluginConfiguration(pluginId);
                conf.PluginsConfiguration.Add(config);
            }
            config.Configuration = pluginConfig;
            config.Placement     = placement;
            config.Order         = order;
        }