Exemplo n.º 1
0
        /// <summary>
        /// Bind the values to the given configuration
        /// </summary>
        /// <param name="binder">The binder.</param>
        /// <param name="objectType"></param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="serializer">The serializer.</param>
        public static object Bind([NotNull] this IJsonBinder binder, Type objectType, IConfiguration configuration, JsonSerializer serializer)
        {
            if (binder == null)
            {
                throw new ArgumentNullException(nameof(binder));
            }

            return(binder.Bind(objectType, GetValues(configuration), serializer));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populate the values from the given configuration object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="binder">The binder.</param>
        /// <param name="value">The value.</param>
        /// <param name="configuration">The configuration.</param>
        public static T Populate <T>([NotNull] this IJsonBinder binder, T value, IConfiguration configuration)
            where T : class
        {
            if (binder == null)
            {
                throw new ArgumentNullException(nameof(binder));
            }

            return(binder.Populate(value, GetValues(configuration)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Bind the values to the given configuration
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="binder">The binder.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="serializer">The serializer.</param>
        public static T Bind <T>([NotNull] this IJsonBinder binder, IConfiguration configuration, JsonSerializer serializer)
            where T : class, new()
        {
            if (binder == null)
            {
                throw new ArgumentNullException(nameof(binder));
            }

            return(binder.Bind <T>(GetValues(configuration), serializer));
        }