using System;
using Common.Logging;
using GeoAPI;
namespace SharpMap
{
///
/// A SharpMap Session class
///
public class Session : ISession
{
private static ICoordinateSystemRepository _repository;
private ICoordinateSystemServices _coordinateSystemServices;
///
/// Static constructor
///
static Session()
{
Instance = new Session();
}
///
/// Gets a value indicating the current instance
///
public static ISession Instance { get; private set; }
///
/// The geometry services instance
///
public IGeometryServices GeometryServices { get; set; }
///
/// Gets the coordinate system services instance
///
public ICoordinateSystemServices CoordinateSystemServices
{
get
{
if (_coordinateSystemServices == null)
throw new InvalidOperationException("Must declare a coordinate system services object!");
return _coordinateSystemServices;
}
set { _coordinateSystemServices = value; }
}
///
/// Gets the coordinate system repository
///
public ICoordinateSystemRepository CoordinateSystemRepository
{
get { return _repository ?? CoordinateSystemServices as ICoordinateSystemRepository; }
set { _repository = value; }
}
#region Fluent
///
/// Method to set the geometry services class
///
/// The geometry services class
/// A reference to this session
public ISession SetGeometryServices(IGeometryServices geometryServices)
{
GeometryServices = geometryServices;
return this;
}
///
/// Method to set the coordinate system services class
///
/// The coordinate system services class
/// A reference to this session
public ISession SetCoordinateSystemServices(ICoordinateSystemServices coordinateSystemServices)
{
CoordinateSystemServices = coordinateSystemServices;
return this;
}
///
/// Method to set the coordinate system repository class
///
/// The coordinate system repository class
/// A reference to this session
public ISession SetCoordinateSystemRepository(ICoordinateSystemRepository coordinateSystemRepository)
{
CoordinateSystemRepository = coordinateSystemRepository;
return this;
}
///
/// Method to read the configuration
///
/// A reference to this session
public ISession ReadConfiguration()
{
var log = LogManager.GetLogger();
log.Warn(f => f("Configuring SharpMap session via ReadConfiguration currently not supported"));
return this;
}
#endregion
}
}