当前位置: 首页>>代码示例>>C#>>正文


C# IProject.AddError方法代码示例

本文整理汇总了C#中IProject.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# IProject.AddError方法的具体用法?C# IProject.AddError怎么用?C# IProject.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProject的用法示例。


在下文中一共展示了IProject.AddError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary>
        /// Ensure the parameters are correct.
        /// </summary>
        /// <param name='p_Context'>
        /// The underlying project.
        /// </param>
        /// <returns>
        /// False if there were no parse errors.
        /// </returns>
        public bool Parse(IProject p_Context)
        {
            bool errors = false;
            BoolHelper.AddBool(errors, this.a1.Parse(p_Context));
            BoolHelper.AddBool(errors, this.sigma1.Parse(p_Context));

            if (this.zr.Expression.IndexOf("@") == -1)
            {
                p_Context.AddError(this.zr.Expression + " is not a reference to a zero rate curve");
            }

            object zrReference = Engine.Parser.EvaluateAsReference(this.zr.Expression);
            if (!Engine.Parser.GetParserError())
            {
                this.zeroRateCurve = zrReference as Function;
                if (this.zeroRateCurve == null)
                {
                    errors = true;

                    p_Context.AddError("Cannot find the Zero Rate Curve! " + this.zr.Expression);
                }

            }
            else
                errors = true;

            if (!errors)
            {
                this.alpha1Temp = this.a1.fV();
                this.sigma1Temp = this.sigma1.fV();
                this.sigma1SquaredTemp = Math.Pow(this.sigma1Temp, 2);
                CalculateGamma();
            }

            return errors;
        }
开发者ID:fairmat,项目名称:InterestRatesModels,代码行数:45,代码来源:Pelsser.cs

示例2: Validation

        /// <summary>
        /// Validates the data of the object.
        /// </summary>
        /// <returns>true if the data has been successfully validated, false otherwise.</returns>
        private bool Validation(IProject p_Context)
        {
            // The start date must antecede than the end date
            bool valid=this.StartDate.CompareTo(EndDate) <= 0;
            if (!valid && p_Context != null)
            {
                p_Context.AddError("Date Sequence " + VarName + " is not valid: 'Start Date' must antecede 'End Date'");
            }

            return valid;
        }
开发者ID:fairmat,项目名称:ModelingTools,代码行数:15,代码来源:ModelParameterDateSequence.cs

示例3: Parse

        /// <summary>
        /// Parses the object and checks if all the restraints of the 2D Point Function
        /// have been respected, if not will return an error to the parser.
        /// </summary>
        /// <remarks>
        /// Note that this method caches the object status, so any changes done to its data
        /// will require this method to be called again in order to update the cache.
        /// </remarks>
        /// <param name="context">The project in which to parse the object.</param>
        /// <returns>True if an error occurred during the parsing, False otherwise.</returns>
        public override bool Parse(IProject context)
        {
            try
            {
                this.function = new CPointFunction2D(this.coordinatesX, this.coordinatesY,
                                                     this.values, this.interpolationType,
                                                     this.extrapolationType);
                CreateSymbol(context as Project);
            }
            catch (Exception e)
            {
                string msg = e.Message + " for the 2D Function " + base.Name;
                if (context != null)
                {
                    context.AddError(msg);
                }
                else
                {
                    throw e;
                }

                // Return true as an error was raised during the parsing.
                return true;
            }

            // Return false as no error have raised during the parsing.
            return false;
        }
开发者ID:GaikovM,项目名称:ModelingTools,代码行数:38,代码来源:PFunction2D.cs

示例4: RetrieveCurve

        /// <summary>
        /// Retrieves zr and dy curve from the model.
        /// </summary>
        /// <param name="p_Context">The parameter is not used.</param>
        /// <param name="errors">
        /// The current status of errors, if errors happened previously to this call.
        /// </param>
        /// <returns>True if there have been errors during this call or before.</returns>
        private bool RetrieveCurve(IProject p_Context, bool errors)
        {
            // check the presence of a zero rate curve
            object zrref = Engine.Parser.EvaluateAsReference(this.r.Expression);
            if (!Engine.Parser.GetParserError())
            {
                this.zrCurve = zrref as Function;
                if (this.zrCurve == null)
                {
                    errors = true;
                    p_Context.AddError("Cannot find the zero rate curve " +
                                       this.r.Expression);
                }
            }
            else
                errors = true;

            // check the presence of a dividend yield curve
            object dyref = Engine.Parser.EvaluateAsReference(this.q.Expression);
            if (!Engine.Parser.GetParserError())
            {
                this.dyCurve = dyref as Function;
                if (this.dyCurve == null)
                {
                    errors = true;
                    p_Context.AddError("Cannot find the dividend yield curve " +
                                       this.q.Expression);
                }
            }
            else
                errors = true;

            return errors;
        }
开发者ID:fairmat,项目名称:EquityModels,代码行数:42,代码来源:Dupire.cs

示例5: Parse

        /// <summary>
        /// Parses the data and ensures the parameters are correct.
        /// </summary>
        /// <param name='p_Context'>
        /// The underlying project.
        /// </param>
        /// <returns>
        /// False if there were no parse errors.
        /// </returns>
        public bool Parse(IProject p_Context)
        {
            this.context = p_Context as Project;
            bool errors = false;

            BoolHelper.AddBool(errors, this._a1.Parse(p_Context));
            BoolHelper.AddBool(errors, this._a2.Parse(p_Context));

            BoolHelper.AddBool(errors, this._s1.Parse(p_Context));
            BoolHelper.AddBool(errors, this._s2.Parse(p_Context));
            BoolHelper.AddBool(errors, this._rho.Parse(p_Context));

            BoolHelper.AddBool(errors, this.driftAdjustment.Parse(p_Context));

            if (this._zr.Expression.IndexOf("@") == -1)
            {
                p_Context.AddError(this._zr.Expression +
                                   " is not a reference to a zero rate curve");
            }

            // Checks for the model constraints: alpha1 != alhpa2
            if (Math.Abs(this._a1.fV() - this._a2.fV()) < 10e-5)
            {
                p_Context.AddError("H&W2:  alpha1 and alpha2 must be different");
            }

            object zr_reference = Engine.Parser.EvaluateAsReference(this._zr.Expression);
            if (!Engine.Parser.GetParserError())
            {
                this.zeroRateCurve = zr_reference as Function;
                if (this.zeroRateCurve == null)
                {
                    errors = true;
                    p_Context.AddError("Cannot find the Zero Rate Curve! " + this._zr.Expression);
                }
            }
            else
                errors = true;

            if (!errors)
            {
                base.alpha1 = this._a1.fV();
                base.sigma1 = this._s1.fV();
                this.sigma1Pow2 = System.Math.Pow(this._s1.fV(), 2);
            }

            CorrelationMatrix R = (p_Context as ProjectProcess).Processes.r;
            int index = (p_Context as ProjectProcess).Processes.GetProcessCorrelationIndex(this);

            // Index is -1 is when the process is not still in the process list.
            if (index != -1)
            {
                // Updates the correlation in the global correlation matrix.
                R.Set(index, index + 1, this._rho);
            }

            return errors;
        }
开发者ID:fairmat,项目名称:InterestRatesModels,代码行数:67,代码来源:HullAndWhiteTwoFactors.cs

示例6: Parse

        /// <summary>
        /// Parses the object.
        /// </summary>
        /// <param name="context">The project in which to parse the object.</param>
        /// <returns>True if an error occurred during the parsing, False otherwise.</returns>
        public override bool Parse(IProject context)
        {
            try
            {
                function = new CPointFunction2D(cordinatesX, cordinatesY, values,
                                                interpolationType, extrapolationType);
            }
            catch (Exception e)
            {
                context.AddError(e.Message + " for the 2D Function " + base.Name);
                return false;
            }

            return base.Parse(context);
        }
开发者ID:weltall,项目名称:PFunction2D,代码行数:20,代码来源:PFunction2D.cs

示例7: Parse

        /// <summary>
        /// Ensure the parameters are correct.
        /// </summary>
        /// <param name='p_Context'>
        /// The underlying project.
        /// </param>
        /// <returns>
        /// False if the parameter were correct.
        /// </returns>
        public bool Parse(IProject p_Context)
        {
            bool errors = false;
            List<IExportable> list = this.ExportObjects(false);
            foreach (IExportable parameter in list)
            {
                if (parameter is IParsable)
                    BoolHelper.AddBool(errors, (parameter as IParsable).Parse(p_Context));
            }

            if (this.zrReference.Expression.IndexOf("@") == -1)
            {
                p_Context.AddError(this.zrReference.Expression +
                                   " is not a reference to a zero rate curve");
            }

            if (this.dyReference.Expression.IndexOf("@") == -1)
            {
                p_Context.AddError(this.dyReference.Expression +
                                   " is not a reference to a dividend yield curve");
            }

            return RetrieveCurve(p_Context, errors);
        }
开发者ID:fairmat,项目名称:EquityModels,代码行数:33,代码来源:HestonExtendedProcess.cs


注:本文中的IProject.AddError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。