internal static NamespaceModel MapToNamespaceModel(this SettingNamespace settingNamespace, string namespacesPath, GrViewModelBase viewModel)
        {
            var result = new NamespaceModel
            {
                NamespacePath = namespacesPath,
                Namespace     = settingNamespace,
                Settings      = new ObservableCollection <SettingModel>(),
            };

            viewModel.BindModel(result);
            return(result);
        }
Esempio n. 2
0
        private List <NamespaceModel> GetNamespaceModels(SettingNamespace settingNamespace, string namespacesPath, IReadOnlyCollection <SettingType> types, List <SettingValueError> settingValueErrors, GrViewModelBase viewModel)
        {
            var resultSpace = settingNamespace.MapToNamespaceModel(namespacesPath, viewModel);
            var result      = new List <NamespaceModel>
            {
                resultSpace,
            };

            if (!settingNamespace.Namespaces.IsNullOrEmpty())
            {
                foreach (var nSpase in settingNamespace.Namespaces)
                {
                    result.AddRange(GetNamespaceModels(nSpase, namespacesPath + settingNamespace.Name + " > ", types, settingValueErrors, viewModel));
                }
            }

            if (!settingNamespace.Settings.IsNullOrEmpty())
            {
                resultSpace.Visibility = Visibility.Visible;

                foreach (var setting in settingNamespace.Settings)
                {
                    var type  = types.First(t => t.Code.EqualsOrdinalIgnoreCase(setting.Type));
                    var model = new SettingModel
                    {
                        Setting     = setting,
                        _value      = setting.Value,
                        SettingType = type,
                        ValueError  = settingValueErrors?.FirstOrDefault(pattern => pattern.SettingFullCode.EqualsOrdinalIgnoreCase(setting.FullCode)),
                    };
                    viewModel.BindModel(model);
                    resultSpace.Settings.Add(model);
                }
            }
            else
            {
                resultSpace.Visibility = Visibility.Collapsed;
            }

            return(result);
        }