Noobie Question about Setting Classes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
Hi

I am trying to understand how everything works to understand design patterns and improve the way I build as a noob.

I am looking in the blog controller which has:

this._blogSettings = blogSettings;

I understand where it is, but I can't figure out how it gets populated, can someone people point me in the right direction
12 年 前
The short answer is the DI library fills it for you when you inject it in the constructor.

The long answer eventually leads you to  Nop.Services.Configuration.ConfigurationProvider<TSettings> which fills the properties based on their name matching the key in the Setting table


// get properties we can write to
var properties =
    from prop in typeof(TSettings).GetProperties()
    where prop.CanWrite && prop.CanRead
    let setting = _settingService.GetSettingByKey<string>(typeof(TSettings).Name + "." + prop.Name)
    where setting != null
    where CommonHelper.GetNopCustomTypeConverter(prop.PropertyType).CanConvertFrom(typeof(string))
    let value = CommonHelper.GetNopCustomTypeConverter(prop.PropertyType).ConvertFromInvariantString(setting)
    select new { prop, value };
12 年 前
Thanks, I knew the Di would create the instance but didn't know the rest.

Many thanks.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.