public static void Main()
IAttedanceController attedanceController = DIContainer.resolve<IAttedanceController>("AttedanceController");
attedanceController.run();
Console.WriteLine("Hello World");
public static T resolve<T> (string entity) {
return (T)Convert.ChangeType(entity, typeof(T));
interface IFingerprintSignature {
void showMessage(string message);
interface IAttedanceController
interface IFingerprintHandler
void processFingerprint(IFingerprintSignature fingerprintSignature);
interface IFingerprintScanner
void run(IFingerprintHandler fingerprintHandler);
interface IAttendanceService
bool attempEmployeeLogin(IFingerprintSignature fingerprintSignature);
string getFailureMessage();
interface ILoginRepository
bool loginEmployee(IEmployee employee, DateTime timestamp);
interface IEmployeeRepository
IEmployee findEmployee(IFingerprintSignature fingerprintSignature);
class AttendanceService : IAttendanceService
private IEmployeeRepository _employeeRepository;
private ILoginRepository _loginRepository;
private string _failureMessage;
public AttendanceService(
IEmployeeRepository employeeRepository,
ILoginRepository loginRepository)
this._employeeRepository = employeeRepository;
this._loginRepository = loginRepository;
public bool attempEmployeeLogin(IFingerprintSignature fingerprintSignature)
IEmployee employee = this._employeeRepository.findEmployee(fingerprintSignature);
this._loginRepository.loginEmployee(employee, DateTime.Now);
this._failureMessage = "employee not found";
public string getFailureMessage()
return "reason for failure";
public void startService()
this._employeeRepository.open();
this._loginRepository.open();
public void stopService()
this._employeeRepository.close();
this._loginRepository.close();
class AttendanceController : IAttedanceController, IFingerprintHandler
private ILoginView _loginView;
private IAttendanceService _attedanceService;
private IFingerprintScanner _fingerprintScanner;
public AttendanceController(
IAttendanceService attendanceService,
IFingerprintScanner fingerprintScanner)
this._loginView = loginView;
this._attedanceService = attendanceService;
this._fingerprintScanner = fingerprintScanner;
this._attedanceService.startService();
this._fingerprintScanner.run(this);
public void processFingerprint(IFingerprintSignature fingerprintSignature)
if(this._attedanceService.attempEmployeeLogin(fingerprintSignature))
this._loginView.showMessage("Login successful");
string errorMessage = this._attedanceService.getFailureMessage();
this._loginView.showMessage("Error message");