コード例 #1
0
        /// <summary>
        ///     Validate field in form with/without analysis type selector
        ///     and writing result with current field
        /// </summary>
        /// <param name="nameField">Value of name field</param>
        /// <param name="valueField">Value of field</param>
        /// <param name="valueSelector">Value of selector, default = null</param>
        /// <returns>True - data in field is valid, value done for transit to device, False - data in field is not valid</returns>
        public bool Validate(string nameField, string valueField, string valueSelector = null)
        {
            try
            {
                NameField = nameField;

                if (valueSelector != null)
                {
                    ComponentModel = new TwoComponentBlocksModel(NameField, valueField, valueSelector);
                }
                else
                {
                    ComponentModel = new OneComponentBlocksModel(NameField, valueField);
                }

                if (ComponentModel.Validate())
                {
                    SetProperty(valueField);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }