// This is a bit of a hack to address a design deficiency in FIXatdl 1.1, whereby when doing order amendments
        // the state of any helper controls is not directly available from the input FIX fields.
        // To simplify matters, we only apply this algorithm in the scenario when the StateRule's immediate Edit_t
        // has a toggleable control as its source and the operator is 'EQ' (this is the same as atdl4j as at the
        // time of writing).
        private void UpdateRelatedHelperControls(Control_t control)
        {
            foreach (StateRule_t stateRule in control.StateRules)
            {
                Edit_t <Control_t> edit = stateRule.Edit;

                if (stateRule.Value == Atdl.NullValue && edit.Operator == Operator_t.Equal)
                {
                    string sourceControlId = edit.Field;

                    if (IsValidControlId(sourceControlId))
                    {
                        Control_t sourceControl = this[sourceControlId];

                        bool result;

                        if (sourceControl.IsToggleable && bool.TryParse(edit.Value, out result))
                        {
                            // If the control is a radio button, then we can only set directly, un-set
                            // has be done by setting its companion control
                            if (sourceControl is CheckBox_t || !result)
                            {
                                sourceControl.SetValue(!result);
                            }
                            else
                            {
                                SetCompanionRadioButton(sourceControl as RadioButton_t);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Recursively copies an edit from this collection.  Used to handle EditRefs.
        /// </summary>
        /// <param name="source">Instance of Edit_t to be copied.</param>
        /// <returns>Copy of source Edit_t instance.</returns>
        private Edit_t <T> Copy <T>(Edit_t source) where T : class, IValueProvider
        {
            Edit_t <T> target = new Edit_t <T>()
            {
                Field = source.Field, Field2 = source.Field2, LogicOperator = source.LogicOperator, Operator = source.Operator, Value = source.Value
            };

            foreach (Edit_t child in source.Edits)
            {
                target.Edits.Add(Copy <T>(child));
            }

            return(target);
        }