コード例 #1
0
        /// <summary>
        /// Apply configuration for this extension.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="target">an existing object that the settings will get JSON serialized onto</param>
        /// <param name="section">specifies a section from the overall config that should apply to this object.</param>
        public static void ApplyConfig(this ExtensionConfigContext context, object target, string section = null)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            JObject hostMetadata = context.GetConfig(target, section);

            if (hostMetadata == null)
            {
                return;
            }

            JsonConvert.PopulateObject(hostMetadata.ToString(), target);
        }