/// <summary> /// Setups the model and Form fields. /// </summary> /// <param name="form">The form</param> /// <param name="model">The IO bject model</param> /// <param name="fieldName">The field name</param> /// <param name="control">The object model iucontrol</param> /// <param name="id">The identifier setting. Default value = -1.</param> /// <code>CTIM_Generation;</code> public void ModelField(IObjectModel model, Form form, string fieldName, IUControl_ObjectModel control, int id = -1) { //================= // Generated @ 2015/07/20 // Generated from 'BlueprintUI.Windows.libUI.WinForms.ModelField'() -> the parameter order was changed to ensure better MTIN results after transformations. ModelField(form, model, fieldName, control, id); }
/// <summary> /// Setups the model and Form fields. /// </summary> /// <param name="form">The form</param> /// <param name="model">The IO bject model</param> /// <param name="fieldName">The field name</param> /// <param name="control">The object model iucontrol</param> /// <param name="id">The identifier setting. Default value = -1.</param> /// <code GenerateParameter1="model"></code> public void ModelField(Form form, IObjectModel model, string fieldName, IUControl_ObjectModel control, int id = -1) { // Double check value before assignment! // ===================================== var type = model.GetType(); BlueprintData_FieldAttribute[] fieldDefinition = null; FieldInfo fieldInfo1 = type.GetField(fieldName); if (fieldInfo1 != null) { fieldDefinition = (BlueprintData_FieldAttribute[])fieldInfo1.GetCustomAttributes(typeof(BlueprintData_FieldAttribute), false); } else { PropertyInfo propertyInfo = type.GetProperty(fieldName); if (propertyInfo != null) { fieldDefinition = (BlueprintData_FieldAttribute[])propertyInfo.GetCustomAttributes(typeof(BlueprintData_FieldAttribute), false); } } if (fieldDefinition == null) { var errMsg = "Error! Field '{0}.{1}' does not exist!".zFormat(type.ToString(), fieldName); throw new ArgumentException(errMsg, nameof(fieldName)); } // Check the ID value // ================== var fieldId = fieldDefinition.Length > 0 ? fieldDefinition[0].Id : -1; if (id != -1) { if (id != fieldId) { string msg = "Error in object mapping!".NL() + "Field '{0}.{1}'".zFormat(type.ToString(), fieldName).NL() + "{0} id = {1} (and not {2} as expected)".zFormat(fieldName, fieldId, id); throw new ArgumentException(msg, nameof(id)); } } control.Field_Name = fieldName; // Map the field; // Update the field value on the form Lamedal_WinForms.Instance.libUI.WinForms.FormGenerate.Form_FromObject(form, model, fieldName); // Sync form }