ParserErrorCollection クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説ParserErrorCollection クラスは、ParserError オブジェクトのコレクションを管理するために使用できるメソッドとプロパティを提供します。たとえば、解析時に、カスタムの BuildProvider オブジェクトを使用して解析中にキャッチされるすべての解析例外を報告すると同時に、一連のパーサー エラーをコレクションに追加できます。
使用例ParserErrorCollection メソッドを使用する方法を次のコード例に示します。
' Create an empty ParserErrorCollection. Dim collection As New ParserErrorCollection() ' Add a ParserError to the collection. collection.Add(New ParserError("ErrorName", "Path", 1)) ' Add an array of ParserError objects to the collection. Dim errors As ParserError() = _ {New ParserError("Error 2", "Path", 1), _ New ParserError("Error 3", "Path", 1)} collection.AddRange(errors) ' Ads a collection of ParserError objects to the collection. Dim errorsCollection As New ParserErrorCollection() errorsCollection.Add(New ParserError("Error", "Path", 1)) errorsCollection.Add(New ParserError("Error", "Path", 1)) collection.AddRange(errorsCollection) ' Test for the presence of a ParserError in the ' collection, and retrieve its index if it is found. Dim testError As New ParserError("Error", "Path", 1) Dim itemIndex As Integer = -1 If collection.Contains(testError) Then itemIndex = collection.IndexOf(testError) End If ' Copy the contents of the collection to a ' compatible array, starting at index 0 of the ' destination array. Dim errorsToSort(5) As ParserError collection.CopyTo(errorsToSort, 0) ' Retrieve the count of the items in the collection. Dim collectionCount As Integer = collection.Count ' Insert a ParserError at index 0 of the collection. Dim [error] As New ParserError("Error", "Path", 1) collection.Insert(0, [error]) ' Remove the specified ParserError from the collection. collection.Remove([error]) ' Remove the ParserError at index 0. collection.RemoveAt(0)
// Create an empty ParserErrorCollection. ParserErrorCollection collection = new ParserErrorCollection(); // Add a ParserError to the collection. collection.Add(new ParserError("ErrorName", "Path", 1)); // Add an array of ParserError objects to the collection. ParserError[] errors = { new ParserError("Error 2", "Path", 1), new ParserError("Error 3", "Path", 1) }; collection.AddRange(errors); // Add a collection of ParserError objects to the collection. ParserErrorCollection errorsCollection = new ParserErrorCollection(); errorsCollection.Add(new ParserError("Error", "Path", 1)); errorsCollection.Add(new ParserError("Error", "Path", 1)); collection.AddRange(errorsCollection); // Test for the presence of a ParserError in the // collection, and retrieve its index if it is found. ParserError testError = new ParserError("Error", "Path", 1); int itemIndex = -1; if (collection.Contains(testError)) itemIndex = collection.IndexOf(testError); // Copy the contents of the collection to a // compatible array, starting at index 0 of the // destination array. ParserError[] errorsToSort = new ParserError[5]; collection.CopyTo(errorsToSort, 0); // Retrieve the count of the items in the collection. int collectionCount = collection.Count; // Insert a ParserError at index 0 of the collection. ParserError error = new ParserError("Error", "Path", 1); collection.Insert(0, error); // Remove the specified ParserError from the collection. collection.Remove(error); // Remove the ParserError at index 0. collection.RemoveAt(0);
継承階層System.Collections.CollectionBase
System.Web.ParserErrorCollection
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- ParserErrorCollection クラスのページへのリンク