コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChartBulletSeries{TModel, TCurrent, TTarget}"/> class.
        /// </summary>
        /// <param name="targetExpression">The expression used to extract the point target from the chart model.</param>
        /// <param name="currentExpression">The expression used to extract the point current from the chart model.</param>
        /// <param name="colorExpression">The expression used to extract the point color from the chart model.</param>
        /// <param name="categoryExpression">The expression used to extract the point category from the chart model.</param>
        /// <param name="noteTextExpression">The expression used to extract the point note text from the chart model.</param>
        public ChartBulletSeries(
            Expression <Func <TModel, TValue> > currentExpression,
            Expression <Func <TModel, TValue> > targetExpression,
            Expression <Func <TModel, string> > colorExpression,
            Expression <Func <TModel, TCategory> > categoryExpression,
            Expression <Func <TModel, string> > noteTextExpression)
        {
            if (typeof(TModel).IsPlainType() && !currentExpression.IsBindable())
            {
                throw new InvalidOperationException(Exceptions.MemberExpressionRequired);
            }

            CurrentMember = currentExpression.MemberWithoutInstance();

            if (typeof(TModel).IsPlainType() && !targetExpression.IsBindable())
            {
                throw new InvalidOperationException(Exceptions.MemberExpressionRequired);
            }

            TargetMember = targetExpression.MemberWithoutInstance();

            if (colorExpression != null)
            {
                if (typeof(TModel).IsPlainType() && !colorExpression.IsBindable())
                {
                    throw new InvalidOperationException(Exceptions.MemberExpressionRequired);
                }

                ColorMember = colorExpression.MemberWithoutInstance();
            }

            if (categoryExpression != null)
            {
                if (typeof(TModel).IsPlainType() && !categoryExpression.IsBindable())
                {
                    throw new InvalidOperationException(Exceptions.MemberExpressionRequired);
                }

                Category       = categoryExpression.Compile();
                CategoryMember = categoryExpression.MemberWithoutInstance();
            }

            if (noteTextExpression != null)
            {
                if (typeof(TModel).IsPlainType() && !noteTextExpression.IsBindable())
                {
                    throw new InvalidOperationException(Exceptions.MemberExpressionRequired);
                }

                NoteTextMember = noteTextExpression.MemberWithoutInstance();
            }

            if (string.IsNullOrEmpty(Name))
            {
                Name = CurrentMember.AsTitle();
            }

            Initialize();
        }