/// <summary>
        /// Sets the Expression property of ExpressionAnimation by converting
        /// the given Expression to appropriate string
        /// </summary>
        /// <typeparam name="T">Type of the Expression</typeparam>
        /// <param name="animation">ExpressionAnimation</param>
        /// <param name="expression">Expression</param>
        /// <returns>Dictionary of parameter names and the parameters</returns>
        public static Dictionary <string, object> SetExpression <T>(this ExpressionAnimation animation,
                                                                    Expression <CompositionLambda <T> > expression)
        {
            var result = CompositionExpressionEngine.CreateCompositionExpression(expression);

            animation.Expression = result.Expression;
            animation.SetParameters(result.Parameters);

            return(result.Parameters);
        }
        /// <summary>
        /// Inserts a KeyFrame in the KeyFrameAnimation by converting
        /// the given Expression to appropriate string
        /// </summary>
        /// <typeparam name="T">Type of the Expression</typeparam>
        /// <param name="animation">KeyFrameAnimation</param>
        /// <param name="normalizedProgressKey">The time the key frame should occur at, expressed as
        /// a percentage of the animation Duration. Allowed value is from 0.0 to 1.0.</param>
        /// <param name="expression">The expression used to calculate the value of the key frame.</param>
        /// <param name="easingFunction">Easing Function (optional)</param>
        /// <returns>KeyFrameAnimation</returns>
        public static KeyFrameAnimation InsertExpressionKeyFrame <T>(this KeyFrameAnimation animation, float normalizedProgressKey,
                                                                     Expression <CompositionLambda <T> > expression, CompositionEasingFunction easingFunction = null)
        {
            var result = CompositionExpressionEngine.CreateCompositionExpression(expression);

            animation.InsertExpressionKeyFrame(normalizedProgressKey, result.Expression, easingFunction);
            animation.SetParameters(result.Parameters);

            return(animation);
        }
        /// <summary>
        /// Creates an ExpressionAnimation based on the given CompositionLambda Expression
        /// </summary>
        /// <typeparam name="T">Type of the CompositionLambda Expression</typeparam>
        /// <param name="compositor">Compositor</param>
        /// <param name="expression">CompositionLambda Expression</param>
        /// <returns>ExpressionAnimation</returns>
        public static ExpressionAnimation CreateExpressionAnimation <T>(this Compositor compositor,
                                                                        Expression <CompositionLambda <T> > expression)
        {
            var result    = CompositionExpressionEngine.CreateCompositionExpression(expression);
            var animation = compositor.CreateExpressionAnimation();

            animation.Expression = result.Expression;
            animation.SetParameters(result.Parameters);

            return(animation);
        }