/// <summary> /// Initializes a new instance of the <see cref="SettingItemViewModel"/> class. /// </summary> /// <param name="info"></param> /// <param name="setting"></param> public SettingItemViewModel(SettingInfo info, SettingItem setting) { Assertions.AssertNotNull(info, "info"); Assertions.AssertNotNull(setting, "setting"); Info = info; Setting = setting; // Find out editor string editorName = Editor; if (string.IsNullOrWhiteSpace(editorName)) { editorName = Setting.SettingType.FullName; } this.TypeEditor = TypeEditors.TypeEditorCache.CreateTypeEditor(editorName); this.TypeEditor.Initialize(this.EditorParameter); try { this.TypeEditor.Value = Setting.Value; } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.SettingItemViewModelSetSettingError, Info.Name, Info.Identifier); Logger.Instance.LogException(this, ex); Setting.ResetValue(); this.TypeEditor.Value = Setting.Value; } }