示例#1
0
        /// <summary>
        /// Equals method overloaded to compare two values of the same data type.
        /// </summary>
        /// <param name="obj">The object to compare with.</param>
        /// <returns>true, if both values are equals, otherwise false.</returns>
        public override bool Equals(object obj)
        {
            YearMonthDuration compareTo = obj as YearMonthDuration;

            if (compareTo == null)
            {
                return(base.Equals(obj));
            }

            return(_months == compareTo._months && _years == compareTo._years && _negative == compareTo._negative);
        }
示例#2
0
        /// <summary>
        /// Evaluates the function.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <param name="args">The function arguments.</param>
        /// <returns>The result value of the function evaluation.</returns>
        public override EvaluationValue Evaluate(EvaluationContext context, params inf.IFunctionParameter[] args)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            DateTime baseDate = GetDateTimeArgument(args, 0);

            typ.YearMonthDuration yearMonthDuration = (typ.YearMonthDuration)args[1].GetTypedValue(DataTypeDescriptor.YearMonthDuration, 1);

            baseDate = baseDate.AddYears(yearMonthDuration.Years);
            baseDate = baseDate.AddMonths(yearMonthDuration.Months);

            return(new EvaluationValue(baseDate, DataTypeDescriptor.DateTime));
        }