コード例 #1
0
 public void CreateViewDataObject(int activeSiteScopeConfiguration, string rootSettingClass = null)
 {
     _viewData[ViewDataKey] = new SiteDependingSettingData()
     {
         ActiveSiteScopeConfiguration = activeSiteScopeConfiguration,
         RootSettingClass             = rootSettingClass
     };
 }
コード例 #2
0
        public void GetOverrideKeys(object settings, object model, int siteId, ISettingService settingService, bool isRootModel = true)
        {
            if (siteId <= 0)
            {
                return;         // single store mode -> there are no overrides
            }
            var data = Data;

            if (data == null)
            {
                data = new SiteDependingSettingData();
            }

            var settingName = settings.GetType().Name;
            var properties  = settings.GetType().GetProperties();

            var modelType = model.GetType();

            foreach (var prop in properties)
            {
                var name          = prop.Name;
                var modelProperty = modelType.GetProperty(name);

                if (modelProperty == null)
                {
                    continue;   // setting is not configurable or missing or whatever... however we don't need the override info
                }
                var key     = settingName + "." + name;
                var setting = settingService.GetSettingByKey <string>(key, siteId: siteId);

                if (setting != null)
                {
                    data.OverrideSettingKeys.Add(key);
                }
            }

            if (isRootModel)
            {
                data.ActiveSiteScopeConfiguration = siteId;
                data.RootSettingClass             = settingName;

                _viewData[ViewDataKey] = data;
            }
        }