Beispiel #1
0
        /// <summary>
        /// Execute a mapping from the plugin descriptor to the plugin model
        /// </summary>
        /// <typeparam name="TModel">Model type</typeparam>
        /// <param name="pluginDescriptor">Plugin descriptor to map from</param>
        /// <param name="model">Model to map into; pass null to map to the new model</param>
        /// <returns>Mapped model</returns>
        public static TModel ToPluginModel <TModel>(this PluginDescriptor pluginDescriptor, TModel model = null)
            where TModel : BaseNopModel, IPluginModel
        {
            if (pluginDescriptor == null)
            {
                throw new ArgumentNullException(nameof(pluginDescriptor));
            }

            return(model == null?pluginDescriptor.Map <TModel>() : pluginDescriptor.MapTo(model));
        }