/// <summary>
 /// Gets the field editor.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <returns></returns>
 private static string GetFieldEditor(PropertyInfo prop, FieldEditorAttribute fieldEditorAttr)
 {
     return fieldEditorAttr == null ? prop.PropertyType.ToString() : fieldEditorAttr.DataType;
 }
 /// <summary>Gets the schedule date field vm.</summary>
 /// <param name="prop">The property.</param>
 /// <param name="model">The model.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <returns></returns>
 private ScheduleDateFieldViewModel GetScheduleDateFieldVM(PropertyInfo prop, IEditableRoot model, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
 {
     var vm = ScheduleDateFieldViewModelFactory.CreateExport().Value;
     SetupField(prop, promptAttr, display, vm, model);
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     return vm;
 }
 /// <summary>
 /// Gets the text field vm.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="model">The model.</param>
 /// <param name="textAttr">The text attribute.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <returns></returns>
 private TextFieldViewModel GetTextFieldVM(PropertyInfo prop, IEditableRoot model, TextFieldAttribute textAttr, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
 {
     var vm = TextFieldViewModelFactory.CreateExport().Value;
     vm.NumberOfRows = textAttr.NumberOfRows;
     vm.Mask = textAttr.Mask;
     vm.MaskType = textAttr.MaskType;
     vm.MaxLength = textAttr.NumberOfCharacters;
     SetupField(prop, promptAttr, display, vm, model);
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     return vm;
 }
 /// <summary>
 /// Gets the date time field vm.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="model">The model.</param>
 /// <param name="dateAttr">The date attribute.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <returns></returns>
 private DateTimeFieldViewModel GetDateTimeFieldVM(PropertyInfo prop, IEditableRoot model, DateTimeFormatAttribute dateAttr, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
 {
     var vm = DateTimeFieldViewModelFactory.CreateExport().Value;
     vm.InputMode = dateAttr.Value;
     SetupField(prop, promptAttr, display, vm, model);
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     return vm;
 }
 /// <summary>
 /// Gets the numeric field view model vm.
 /// </summary>
 /// <param name="prop">The property.</param>
 /// <param name="model">The model.</param>
 /// <param name="promptAttr">The prompt attribute.</param>
 /// <param name="display">The display.</param>
 /// <param name="fieldEditorAttr">The field editor attribute.</param>
 /// <param name="numericAttr">The numeric attribute.</param>
 /// <returns></returns>
 private NumericFieldViewModel GetNumericFieldViewModelVM(PropertyInfo prop, IEditableRoot model, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr, NumericAttribute numericAttr)
 {
     var vm = NumericFieldViewModelFactory.CreateExport().Value;
     SetupField(prop, promptAttr, display, vm, model, 0);
     vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);
     vm.NumericType = numericAttr.NumericType;
     vm.NumberOfDigits = numericAttr.NumberOfDigits;
     return vm;
 }
        /// <summary>
        /// Gets the checkbox field vm.
        /// </summary>
        /// <param name="prop">The property.</param>
        /// <param name="model">The model.</param>
        /// <param name="promptAttr">The prompt attribute.</param>
        /// <param name="display">The display.</param>
        /// <param name="fieldEditorAttr">The field editor attribute.</param>
        /// <returns></returns>
        private FieldViewModel GetCheckboxFieldVM(PropertyInfo prop, IEditableRoot model, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
        {
            var vm = FieldViewModelFactory.CreateExport().Value;
            SetupField(prop, promptAttr, display, vm, model);
            vm.FieldType = GetFieldEditor(prop, fieldEditorAttr);

            foreach (var nameValueAttribute in prop.GetCustomAttributes(typeof(NameValueAttribute), true).Cast<NameValueAttribute>())
                vm.AddProperty(GetAttributeName(nameValueAttribute), nameValueAttribute.Value.GetType(), true);

            foreach (var nameValueAttribute in prop.GetCustomAttributes(typeof(NameValueAttribute), true).Cast<NameValueAttribute>())
                vm.SetPropertyValue(GetAttributeName(nameValueAttribute), nameValueAttribute.Value);

            return vm;
        }
        /// <summary>
        /// Gets the cr field vm.
        /// </summary>
        /// <param name="prop">The property.</param>
        /// <param name="model">The model.</param>
        /// <param name="crossRefAttr">The cross reference attribute.</param>
        /// <param name="promptAttr">The prompt attribute.</param>
        /// <param name="display">The display.</param>
        /// <param name="fieldEditorAttr">The field editor attribute.</param>
        /// <returns></returns>
        private ICrossRefFieldViewModelBase GetCRFieldVM(PropertyInfo prop, IEditableRoot model, CrossRefFieldAttribute crossRefAttr, PromptAttribute promptAttr, DisplayAttribute display, FieldEditorAttribute fieldEditorAttr)
        {
            ICrossRefFieldViewModelBase crossReffieldViewModel;

            dynamic defaultValue = null;
            if (crossRefAttr.AllowMultiple)
            {
                crossReffieldViewModel = MultiCrossRefFieldViewModelFactory.CreateExport().Value;
                var crType = TheDynamicTypeManager.GetCrossReferenceListType(model.ProcessName, prop.Name);
                defaultValue = Activator.CreateInstance(crType);
            }
            else
            {
                var vm = SingleCrossRefFieldViewModelFactory.CreateExport().Value;

                vm.AllowAddNew = false; // crossRefAttr.AllowAddNew;
                vm.AllowViewDetail = false; // crossRefAttr.AllowViewDetail;
                vm.AllowClear = crossRefAttr.AllowClear;

                crossReffieldViewModel = vm;
            }

            crossReffieldViewModel.List = null;
            crossReffieldViewModel.ReferenceName = crossRefAttr.ReferenceTableName;
            crossReffieldViewModel.DisplayField = crossRefAttr.RefFieldName;
            crossReffieldViewModel.DisplayPath = crossRefAttr.DisplayFieldList;
            crossReffieldViewModel.FieldType = crossRefAttr.AllowMultiple ? "MultiCrossRef" : "SingleCrossRef";
            crossReffieldViewModel.ItemProcess = crossRefAttr.ReferenceTableName;


            SetupField(prop, promptAttr, display, crossReffieldViewModel, model, defaultValue);

            crossReffieldViewModel.ItemType = crossReffieldViewModel.List != null
                                                  ? crossReffieldViewModel.List.GetType().BaseType.GetGenericArguments()[1]
                                                  : TheDynamicTypeManager.GetCrossReferenceItemType(model.ProcessName, prop.Name);

            return crossReffieldViewModel;
        }
Exemple #8
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;
 }