コード例 #1
0
        /// <summary>
        /// Sets the value of this control using the value of the supplied parameter.
        /// </summary>
        /// <param name="parameter">Parameter to set this control's value from.</param>
        public override void SetValueFromParameter(IParameter parameter)
        {
            IControlConvertible value = parameter.GetValueForControl();

            _value = value.ToEnumState(parameter.EnumPairs);

            _log.Debug(m => m("List control {0} value is now {1}", Id, _value.ToString()));
        }
コード例 #2
0
        /// <summary>
        /// Updates this EnumState with the state of the supplied EnumState.
        /// </summary>
        /// <param name="source">Source EnumState to update this instance from.</param>
        /// <remarks>Implementation note: there are probably more effective ways to copy data from one BitArray to another that the one taken, but
        /// the current implementation ensures that the two EnumStates reference a common set of EnumIDs.</remarks>
        public void UpdateFrom(EnumState source)
        {
            if (source == null)
            {
                throw ThrowHelper.New <ArgumentNullException>(this, "A valid EnumState must be supplied");
            }

            if (_enumIds.Length != source._enumIds.Length)
            {
                throw ThrowHelper.New <ArgumentException>(this, "Unable to update this EnumState from supplied EnumState as the number of EnumIDs was not consistent");
            }

            _log.Debug(m => m("Updating EnumState from {0} to {1}", this.ToString(), source.ToString()));

            int enumCount = _enumIds.Length;

            for (int n = 0; n < _enumIds.Length; n++)
            {
                for (int index = 0; index < source._enumIds.Length; index++)
                {
                    if (source._enumIds[index] == _enumIds[n])
                    {
                        _enumStates.Set(n, source._enumStates[index]);

                        enumCount--;

                        break;
                    }
                }
            }

            if (enumCount != 0)
            {
                throw ThrowHelper.New <ArgumentException>(this, "Mismatch between the EnumIDs of the source and target EnumState");
            }

            _nonEnumValue = source._nonEnumValue;
        }
コード例 #3
0
        /// <summary>
        /// Creates a new EnumState from the supplied set of EnumPairs and input FIX string.
        /// </summary>
        /// <param name="enumPairs">EnumPairs for this parameter.</param>
        /// <param name="multiValueString">String containing one or more FIX wire values (space-separated).</param>
        /// <returns></returns>
        public static EnumState FromWireValue(EnumPairCollection enumPairs, string multiValueString)
        {
            _log.DebugFormat("Converting WireValue '{0}' to EnumState", multiValueString);

            string[] inputValues = multiValueString.Split(new char[] { ';', ' ', ',' });

            EnumState result = new EnumState(enumPairs.EnumIds);

            foreach (string inputValue in inputValues)
            {
                string enumId;

                if (!enumPairs.TryParseWireValue(inputValue, out enumId))
                {
                    throw ThrowHelper.New <ArgumentException>(ExceptionContext, ErrorMessages.UnrecognisedEnumIdValue, inputValue);
                }

                result[enumId] = true;
            }

            _log.Debug(m => m("Converting EnumState from WireValue; state is {0}", result.ToString()));

            return(result);
        }