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


C# Errors.Add方法代码示例

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


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

示例1: Add_Test2_Adding_string

 public void Add_Test2_Adding_string()
 {
     Errors target = new Errors();
     string newError = "Test";
     target.Add(newError);
     Assert.AreEqual(target[0].Message, newError);
 }
开发者ID:bobtjanitor,项目名称:bob-the-janitor-sample-code,代码行数:7,代码来源:Errors_Tests.cs

示例2: AssertAGP

        bool AssertAGP(Row row, string madeAgpColumn, string ratingColumn, string mgpColumn, Errors errors)
        {
            if(!Defined(row, madeAgpColumn, errors) && !Defined(row, ratingColumn, errors) && !Defined(row, mgpColumn, errors))
            {
                return true;
            }

            if(AssertDefined(row, madeAgpColumn, errors))
            {
                var madeMgp = row[madeAgpColumn];
                Func<double, string> rating = null;
                if (madeMgp.ToLower() == "yes") rating = RatingYes;
                if (madeMgp.ToLower() == "no") rating = RatingNo;
                if(rating != null)
                {
                    return AssertRating(row, ratingColumn, mgpColumn, rating, errors);
                }
                else
                {
                    errors.Add(row, "Unknown Made MGP State (should be 'Yes' or 'No'):" + madeMgp, GetPrettyName());
                }

            }
            return false;
        }
开发者ID:jperdue,项目名称:cde-export,代码行数:25,代码来源:AcademicGrowthAndGrowthGapsRating.cs

示例3: Add_Test1_Adding_string

 public void Add_Test1_Adding_string()
 {
     Errors target = new Errors(); 
     string newError = string.Empty; 
     target.Add(newError);
     Assert.AreEqual(target.Count,1);
 }
开发者ID:bobtjanitor,项目名称:bob-the-janitor-sample-code,代码行数:7,代码来源:Errors_Tests.cs

示例4: Add_Test2_Adding_Non_Empty_Collection

        public void Add_Test2_Adding_Non_Empty_Collection()
        {
            Errors target = new Errors();
            Errors newErrors = new Errors {"Test Error"};

            target.Add(newErrors);
            Assert.AreEqual(target.Count, 1);
        }
开发者ID:bobtjanitor,项目名称:bob-the-janitor-sample-code,代码行数:8,代码来源:Errors_Tests.cs

示例5: Add_Test1_Adding_Empty_Collection

        public void Add_Test1_Adding_Empty_Collection()
        {
            Errors target = new Errors();
            Errors newErrors = new Errors();
 
            target.Add(newErrors);
            Assert.AreEqual(target.Count,0);
        }
开发者ID:bobtjanitor,项目名称:bob-the-janitor-sample-code,代码行数:8,代码来源:Errors_Tests.cs

示例6: Defined

        protected bool Defined(Row row, string column, Errors errors)
        {
            if(!row.ContainsKey(column))
            {
                errors.Add(row, "Column not defined: " + column, GetPrettyName());
                return false;
            }

            var value = row[column].Trim();

            return !String.IsNullOrEmpty(value) && value != "-";
        }
开发者ID:jperdue,项目名称:cde-export,代码行数:12,代码来源:BaseTest.cs

示例7: AssertTrue

 protected bool AssertTrue(Row row, bool result, string message, Errors errors)
 {
     if (!result)
     {
         errors.Add(row, GetPrettyName() + " - " + message, GetPrettyName());
     }
     return result;
 }
开发者ID:jperdue,项目名称:cde-export,代码行数:8,代码来源:BaseTest.cs

示例8: AssertNumber

 protected bool AssertNumber(Row row, string numberColumn, out double value, Errors errors)
 {
     var numberValue = row[numberColumn];
     if (double.TryParse(numberValue, out value))
     {
         return true;
     }
     errors.Add(row, "Value in '" + numberColumn + "' cannot be converted to a number (" + numberValue + ")", GetPrettyName());
     return false;
 }
开发者ID:jperdue,项目名称:cde-export,代码行数:10,代码来源:BaseTest.cs

示例9: UpdateSchema

 public void UpdateSchema()
 {
     // 1. add declaringtype to widget defs
     // 2. add declaringassembly to widget defs.
     // 3. add description to widget defs.
     // 3. add pathtoeditor to widget defs.
     string con = Config.Get<string>("Database", "connectstr");
     string[] sqlupdates = new string[]
     {
         "ALTER TABLE Events ADD [HasMediaFiles] [bit] NULL; ",
         "ALTER TABLE Events ADD [TotalMediaFiles] [int] NULL;",
         "ALTER TABLE Posts ADD [HasMediaFiles] [bit] NULL; ",
         "ALTER TABLE Posts ADD [TotalMediaFiles] [int] NULL;",
         "ALTER TABLE Profiles ADD [HasMediaFiles] [bit] NULL; ",
         "ALTER TABLE Profiles ADD [TotalMediaFiles] [int] NULL;",
         "ALTER TABLE Widgets ADD [Description] [ntext] NULL, [PathToEditor] [nvarchar](150) NULL, [DeclaringType] [nvarchar](150) NULL, [DeclaringAssembly] [nvarchar](150) NULL; ",
         "ALTER TABLE MediaFiles ADD [Title] [nvarchar](100) NULL;",
         "ALTER TABLE MediaFiles ALTER COLUMN [Description] [nvarchar](200) NULL;",
         "ALTER TABLE MediaFolders ALTER COLUMN [Description] [nvarchar](200) NULL;",
         "ALTER TABLE MediaFolders ADD [HasMediaFiles] [bit] NULL; ",
         "ALTER TABLE MediaFolders ADD [TotalMediaFiles] [int] NULL;",
         "UPDATE users SET createuser = username, updateuser = username"
     };
     var dbhelper = new Database(con);
     var errors = new Errors();
     foreach (string sqlupdate in sqlupdates)
     {
         Try.Catch(
             () => dbhelper.ExecuteNonQueryText(sqlupdate), 
             (ex) => errors.Add("Error updateing schema with command : " + sqlupdate + ". " + ex.Message));
     }
 }
开发者ID:jespinoza711,项目名称:ASP.NET-MVC-CMS,代码行数:32,代码来源:Global.asax.cs

示例10: AssertNumber

 protected bool AssertNumber(Row row, string numberColumn, out double value, Errors errors)
 {
     var result = Number(row, numberColumn, out value);
     var numberValue = row[numberColumn];
     if (!result)
     {
         errors.Add(row, "Value in '" + numberColumn + "' cannot be converted to a number (" + numberValue + ")", GetPrettyName());
     }
     return result;
 }
开发者ID:jakepearson,项目名称:cde-export,代码行数:10,代码来源:BaseTest.cs

示例11: HTMLErrors

        /// <summary>
        /// Method to obtain all the errors as a result of the validation of the html
        /// </summary>
        /// <param name="htmlValid">Boolean that will indicate if the document is or not valid html.</param>
        /// <param name="urlDocument">Xml document that represents the result of the validation</param>
        /// <param name="mNamespace">Namespace using to obtain some data such as line, colum, etc.</param>
        /// <returns>Boolean that will indicate if the document is or not valid html.</returns>
        private Boolean HTMLErrors(Boolean htmlValid, XDocument urlDocument, XNamespace mNamespace)
        {
            errors = new Errors();

            //Obtaining the descendants of the elements labeled "errors". With this we obtain all the errors
            var errorsElements = from e in urlDocument.Descendants(mNamespace + "errors")
                                 select e;
            //Obtaining the descendants of the elements labeled "errorcount". With this we can obtain the number of errors.
            var errorCountElement = from e in errorsElements.Descendants(mNamespace + "errorcount")
                                    select e;
            //Obtaining the descendants of the elements labeled "error". With this we can obtain information from each of the errors. 
            var errorListElements = from e in errorsElements.Descendants(mNamespace + "error")
                                    select e;

            //Iterate over the 'errorcount' variable to obtain the number of errors
            foreach (var element in errorCountElement)
            {
                //Store the value of the count
                errors.errorsCount = element.Value;

                //If the number of errors is greater than 0
                if (int.Parse(errors.errorsCount) > 0)
                    //The document is not a valid html document according to the doctype especified
                    htmlValid = false;

                //Iterate over the 'errorListElements' variable to obtain each error
                foreach (var errorElement in errorListElements)
                {
                    //Create a instance of an Error
                    Error error = new Error();
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "line").Count() > 0)
                        //Store the line
                        error.line = errorElement.Descendants(mNamespace + "line").First().Value;
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "col").Count() > 0)
                        //Store the col
                        error.col = errorElement.Descendants(mNamespace + "col").First().Value;
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "message").Count() > 0)
                        //Store the message
                        error.message = errorElement.Descendants(mNamespace + "message").First().Value;
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "messageid").Count() > 0)
                        //Store the messageid
                        error.messageId = errorElement.Descendants(mNamespace + "messageid").First().Value;
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "explanation").Count() > 0)
                        //Store the explanation
                        error.explanation = errorElement.Descendants(mNamespace + "explanation").First().Value;
                    //If there is a number of line
                    if (errorElement.Descendants(mNamespace + "source").Count() > 0)
                        //Store the source
                        error.source = errorElement.Descendants(mNamespace + "source").First().Value;

                    //Add the error to the list of errors that are stored in the 'errors' variable.
                    errors.Add(error);
                }
            }
            return htmlValid;
        }
开发者ID:AlmatoolboxCE,项目名称:Accessibility,代码行数:68,代码来源:HTMLValidate.cs


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