Skip to content

Instantly share code, notes, and snippets.

@danielsilva
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielsilva/8696652 to your computer and use it in GitHub Desktop.
Save danielsilva/8696652 to your computer and use it in GitHub Desktop.
Elemar´s Employee - http://bit.ly/1d8k32v
using Domain.Employees;
using Domain.Employees.BonusExtensions;
class CanGrantBonus
{
public void Foo()
{
var employee = new Employee(
name: "John Doe",
salary: 1500
);
employee.GrantBonus(200);
}
}
using Domain.Employees;
using Domain.Employees.SalaryExtensions;
class CanRaiseSalary
{
public void Foo()
{
var employee = new Employee(
name: "John Doe",
salary: 1500
);
employee.RaiseSalary(200);
}
}
namespace Domain.Employees
{
public class Employee
{
public Employee(string name, decimal salary)
{
Name = name;
Salary = salary;
}
public string Name { get; private set; }
public decimal Salary { get; internal set; }
}
}
namespace Domain.Employees.BonusExtensions
{
public static class EmployeeBonusExtensions
{
public static void GrantBonus(this Employee employee, decimal amount)
{
employee.Salary += amount;
}
}
}
namespace Domain.Employees.SalaryExtensions
{
public static class EmployeeSalaryExtensions
{
public static void RaiseSalary(this Employee employee, decimal amount)
{
employee.Salary += amount;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment