#region License, Terms and Author(s)
//
// ELMAH - Error Logging Modules and Handlers for ASP.NET
// Copyright (c) 2004-9 Atif Aziz. All rights reserved.
//
// Author(s):
//
// Atif Aziz, http://www.raboof.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion
// All code in this file requires .NET Framework 2.0 or later.
#if !NET_1_1 && !NET_1_0
[assembly: Elmah.Scc("$Id$")]
namespace Elmah
{
#region Imports
using System.Web.UI.WebControls;
using System.Web;
using System.Collections.Generic;
#endregion
///
/// Methods of this type are designed to serve an
/// control
/// and are adapted according to expected call signatures and
/// behavior.
///
public sealed class ErrorLogDataSourceAdapter
{
private readonly ErrorLog _log;
///
/// Initializes a new instance of the
/// class with the default
/// error log implementation.
///
public ErrorLogDataSourceAdapter()
{
_log = ErrorLog.GetDefault(HttpContext.Current);
}
///
/// Use as the value for .
///
public int GetErrorCount()
{
return _log.GetErrors(0, 0, null);
}
///
/// Use as the value for .
///
///
/// The parameters of this method are named after the default values
/// for
/// and so
/// that the minimum markup is needed for the object data source
/// control.
///
public ErrorLogEntry[] GetErrors(int startRowIndex, int maximumRows)
{
return GetErrorsPage(startRowIndex / maximumRows, maximumRows);
}
private ErrorLogEntry[] GetErrorsPage(int index, int size)
{
List list = new List(size);
_log.GetErrors(index, size, list);
return list.ToArray();
}
}
}
#endif