using System;
using Csla.Server;
namespace Csla.DataPortalClient
{
  /// 
  /// Implements a data portal proxy to relay data portal
  /// calls to an application server hosted locally 
  /// in the client process and AppDomain.
  /// 
  public class LocalProxy : DataPortalClient.IDataPortalProxy
  {
    private Server.IDataPortalServer _portal =
      new Server.DataPortal();
    /// 
    /// Called by  to create a
    /// new business object.
    /// 
    /// Type of business object to create.
    /// Criteria object describing business object.
    /// 
    ///  object passed to the server.
    /// 
    public DataPortalResult Create(
      Type objectType, object criteria, DataPortalContext context)
    {
      return _portal.Create(objectType, criteria, context);
    }
    /// 
    /// Called by  to load an
    /// existing business object.
    /// 
    /// Type of business object to retrieve.
    /// Criteria object describing business object.
    /// 
    ///  object passed to the server.
    /// 
    public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
    {
      return _portal.Fetch(objectType, criteria, context);
    }
    /// 
    /// Called by  to update a
    /// business object.
    /// 
    /// The business object to update.
    /// 
    ///  object passed to the server.
    /// 
    public DataPortalResult Update(object obj, DataPortalContext context)
    {
      return _portal.Update(obj, context);
    }
    /// 
    /// Called by  to delete a
    /// business object.
    /// 
    /// Criteria object describing business object.
    /// 
    ///  object passed to the server.
    /// 
    public DataPortalResult Delete(object criteria, DataPortalContext context)
    {
      return _portal.Delete(criteria, context);
    }
    /// 
    /// Get a value indicating whether this proxy will invoke
    /// a remote data portal server, or run the "server-side"
    /// data portal in the caller's process and AppDomain.
    /// 
    public bool IsServerRemote
    {
      get { return false; }
    }
  }
}