Esempio n. 1
0
        protected override void SetValue(TValue value)
        {
            if (DynamicValue) // When overriding a dynamic value, reset the stored data.
            {
                dynamicValueData = default;
            }

            base.SetValue(value);
        }
Esempio n. 2
0
        /// <summary>
        /// Attempts to parse provided script text fragment representing value of the parameter and assign result to the current value.
        /// </summary>
        /// <param name="playbackSpot">Playback spot of the command to which the parameter belong.</param>
        /// <param name="valueText">Parameter value text to parse (see remarks for the expected format).</param>
        /// <param name="errors">Parse errors (if any) or null when the parse has succeeded.</param>
        /// <remarks>
        /// Parameter value is the content after <see cref="Command.ParameterAssignLiteral"/> and before next whitespace (except whitespace inside double quotes).
        /// </remarks>
        public virtual void SetValueFromScriptText(PlaybackSpot playbackSpot, string valueText, out string errors)
        {
            errors = null;

            var expressions = DynamicValueData.CaptureExprRegex.Matches(valueText).Cast <Match>().Select(m => m.Value).ToArray();

            if (expressions.Length > 0)
            {
                // Value contains injected script expressions (dynamic value); keep the text and parse it at runtime.
                dynamicValueData = new DynamicValueData {
                    PlaybackSpot = playbackSpot, ValueText = valueText, Expressions = expressions
                };
                HasValue = true;
            }
            else
            {
                Value    = ParseValueText(valueText, out var hasValue, out errors);
                HasValue = hasValue;
            }
        }