/// <summary> /// Parses information about one field in component. /// Exception thrown if there war error during parsing field info. /// </summary> /// <param name="field">field information wrapped in JSONObject</param> /// <returns>field info wrapped in AFFieldInfo object</returns> private AFFieldInfo parseFieldInfo(JsonObject field) { Debug.WriteLine("PARSING FIELD " + Utils.TryToGetValueFromJson(field[Constants.ID])); AFFieldInfo fieldInfo = new AFFieldInfo(); try { fieldInfo.setWidgetType(Utils.ValueOf<SupportedWidgets>(typeof(SupportedWidgets), (String) Utils.TryToGetValueFromJson(field[Constants.WIDGET_TYPE]))); } catch (Exception e) { Debug.WriteLine(e.Message); } fieldInfo.setId((String) Utils.TryToGetValueFromJson(field[Constants.ID])); fieldInfo.setLabelText((String) Utils.TryToGetValueFromJson(field[Constants.LABEL])); fieldInfo.setIsClass((Boolean) Utils.TryToGetValueFromJson(field[Constants.CLASS_TYPE])); fieldInfo.setVisible((Boolean) Utils.TryToGetValueFromJson(field[Constants.VISIBLE])); fieldInfo.setReadOnly((Boolean) Utils.TryToGetValueFromJson(field[Constants.READ_ONLY])); //field layout fieldInfo.setLayout(createLayoutProperties((JsonObject) Utils.TryToGetValueFromJson(field[Constants.LAYOUT]))); //rules) JsonArray rules = (JsonArray) Utils.TryToGetValueFromJson(field[Constants.RULES]); if (rules != null) { for (int i = 0; i < rules.Count; i++) { fieldInfo.addRule(createRule((JsonObject) Utils.TryToGetValueFromJson(rules[i]))); } } //add number rule - it is not among others in json try { if (fieldInfo.getWidgetType().Equals(SupportedWidgets.NUMBERFIELD) || fieldInfo.getWidgetType().Equals(SupportedWidgets.NUMBERDOUBLEFIELD)) { AFValidationRule numberRule = new AFValidationRule(); numberRule.setValidationType(SupportedValidations.NUMBER); numberRule.setValue(""); fieldInfo.addRule(numberRule); } } catch (Exception e) { Debug.WriteLine(e.Message); } //options JsonArray options = (JsonArray) Utils.TryToGetValueFromJson(field[Constants.OPTIONS]); if (options != null) { for (int i = 0; i < options.Count; i++) { fieldInfo.addOption(createOption((JsonObject) Utils.TryToGetValueFromJson(options[i]))); } } return fieldInfo; }