private IList ConvertToFields(PlusPropertyDescriptorsCollection collection)
        {
            Type type = collection.FirstOrDefault().ModelType;

            IList result = type switch
            {
                Type t when t == typeof(Model.Meter) => new MeterFieldsCollection(),
                Type t when t == typeof(Model.ChangeOfMeter) => new ChangesOfMetersFieldsCollection(),
                Type t when t == typeof(Model.SummaryInfoItem) => new SummaryInfoFieldsCollection(),
                _ => throw new NotImplementedException($"Unknown type '{type}'"),
            };

            foreach (PlusPropertyDescriptor plusProperty in collection)
            {
                result.Add(plusProperty.Name);
            }

            return(result);
        }
Exemplo n.º 2
0
        public AppSettings()
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
            {
                return;
            }

            this.viewModelsTableColumns = new TMP.Shared.SerializableDictionary <string, string>();

            this.defaultSummaryInfoFields = new PlusPropertyDescriptorsCollection(ModelHelper.MeterSummaryInfoItemDescriptors);
            System.Diagnostics.Debug.Assert(this.defaultSummaryInfoFields.Count > 0, "DefaultSummaryInfoFields.Count <= 0");

            this.defaultChangesOfMetersFields = new PlusPropertyDescriptorsCollection(ModelHelper.ChangesOfMetersDescriptors);
            if (this.defaultChangesOfMetersFields.Count == 0)
            {
                System.Diagnostics.Debugger.Break();
            }

            this.Load();

            this.ПолныйViewColumns = Meter.GetSetOfColumns("ПолныйView").ToPlusPropertyDescriptorsCollection();

            this.defaultBaseViewColumns     = Meter.GetSetOfColumns("BaseView").ToPlusPropertyDescriptorsCollection();
            this.defaultShortViewColumns    = Meter.GetSetOfColumns("ShortView").ToPlusPropertyDescriptorsCollection();
            this.defaultDetailedViewColumns = Meter.GetSetOfColumns("DetailedView").ToPlusPropertyDescriptorsCollection();
            this.defaultОплатаViewColumns   = Meter.GetSetOfColumns("ОплатаView").ToPlusPropertyDescriptorsCollection();
            this.defaultПривязкаViewColumns = Meter.GetSetOfColumns("ПривязкаView").ToPlusPropertyDescriptorsCollection();

            if (this.SummaryInfoFields == null || this.SummaryInfoFields.Count == 0)
            {
                this.summaryInfoFields = this.defaultSummaryInfoFields;
            }

            if (this.ChangesOfMetersFields == null || this.ChangesOfMetersFields.Count == 0)
            {
                this.changesOfMetersFields = this.defaultChangesOfMetersFields;
            }

            if (this.BaseViewColumns == null || this.BaseViewColumns.Count == 0)
            {
                this.baseViewColumns = this.defaultBaseViewColumns;
            }

            if (this.ShortViewColumns == null || this.ShortViewColumns.Count == 0)
            {
                this.shortViewColumns = this.defaultShortViewColumns;
            }

            if (this.DetailedViewColumns == null || this.DetailedViewColumns.Count == 0)
            {
                this.detailedViewColumns = this.defaultDetailedViewColumns;
            }

            if (this.ОплатаViewColumns == null || this.ОплатаViewColumns.Count == 0)
            {
                this.оплатаViewColumns = this.defaultОплатаViewColumns;
            }

            if (this.ПривязкаViewColumns == null || this.ПривязкаViewColumns.Count == 0)
            {
                this.привязкаViewColumns = this.defaultПривязкаViewColumns;
            }

            if (this.ViewModelsTableColumns == null)
            {
                this.viewModelsTableColumns = new TMP.Shared.SerializableDictionary <string, string>();
            }
        }