Пример #1
0
 private static void SetupField(PropertyInfo prop, CommonSettingsAttribute commonSettingsAttr, DocumentationAttribute docAttr, PromptAttribute promptAttr, object display, IFieldViewModel fieldViewModel, IEditableRoot model, IDetailsViewModel detailsViewModel)
 {
     fieldViewModel.Property = prop;
     fieldViewModel.Init(model, prop.GetValue(model, null), detailsViewModel);
     fieldViewModel.Label = display == null ? prop.Name : ((DisplayAttribute)display).GetName();
     fieldViewModel.WidthPercentage = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? 0.4 : commonSettingsAttr.Width / 100;
     fieldViewModel.Section = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? string.Empty : commonSettingsAttr.Section;
     fieldViewModel.Position = (commonSettingsAttr == null || commonSettingsAttr.HideFromDetails) ? 0 : commonSettingsAttr.Position;
     fieldViewModel.RowSpan = (commonSettingsAttr == null) ? 1 : commonSettingsAttr.RowSpan;
     fieldViewModel.Section = commonSettingsAttr == null ? string.Empty : commonSettingsAttr.Section;
     fieldViewModel.ShowDocumentation = docAttr != null;
     fieldViewModel.Documentation = docAttr == null ? null : ClrUnicodeConverter.ToText(docAttr.DocumentationBody);
     fieldViewModel.Prompt = promptAttr == null ? string.Format(CultureInfo.InvariantCulture, LanguageService.Translate("Tooltip_EnterPrompt"), fieldViewModel.Label) : promptAttr.PromptString;
     fieldViewModel.IsCalculated = prop.GetCustomAttributes(typeof(CalculatedAttribute), false).Length > 0;
     fieldViewModel.ParentDetailsVM = detailsViewModel;
 }
Пример #2
0
 private IFieldViewModel SetupDateTimeFieldViewModel(PropertyInfo prop, IEditableRoot model,
                                                     IDetailsViewModel detailsViewModel, DateTimeFormatAttribute dateAttr,
                                                     FieldEditorAttribute fieldEditorAttr,
                                                     CommonSettingsAttribute commonSettingsAttr,
                                                     DocumentationAttribute docAttr, PromptAttribute promptAttr,
                                                     object display)
 {
     var vm = DateTimeFieldViewModelFactory.CreateExport().Value;
     vm.InputMode = dateAttr.Value;
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     SetupField(prop, commonSettingsAttr, docAttr, promptAttr, display, vm, model, detailsViewModel);
     return vm;
 }