示例#1
0
        /// <summary>
        /// Retrieves the value with the given <see cref="Id"/> if possible. Otherwise evaluates the <see cref="Code"/>.
        /// </summary>
        /// <param name="engine">Engine to execute code against</param>
        /// <returns>The value from evaluation of the <see cref="Code"/></returns>
        public virtual object GetValue(ICompositionEngine engine)
        {
            if (Id != null)
            {
                var value = engine.GetProperty(Id);
                if (value != null)
                {
                    return(value);
                }
            }
            var rawCode = Code;

            if (engine.ShouldConvertTimeMarks())
            {
                rawCode = new TimeConverter().ReplaceTimespans(rawCode);
            }

            return(engine.Execute(rawCode));
        }