Fluent Interface, Method Chaning, Function Sequence.

I was reading Martin Fowlers Domain Specific Languages book. Few terms from that book really attract me those are Fluent interface, Method chaining and Function Sequence.About the definition of those terms please see Fluent interface, Method chaining and Function sequence( ref: Chapter 33 Function Sequence).

without any more theory I will show an example,

Function Sequence 

namespace FluentConsoleTestHarness
{
    using System;
    class Program
    {
        static void Main(string[] args)
        {
            var areaCalculator = new AreaCalculator();
            Console.WriteLine("Total Six Area : {0}",
                areaCalculator.CalculateSixArea(areaCalculator.CalculateArea(4, 4)));
        }
    }
 
    public class AreaCalculator
    {
        public int CalculateSixArea(int area)
        {
            return area * 6;
        }
        public int CalculateArea(int height, int width)
        {
            return height * width;
        }
    }
}

Output of the program is as below,


Total Six Area : 96
Press any key to continue . . .


Method Chaining and Fluent Interface


namespace FluentConsoleTestHarness
{
    using System;
    class Program
    {
        static void Main(string[] args)
        {
            var netSalary = new TaxCalculator().GrossSalary(2222).CalculateSalary(100).TotalNetPay(10);
            Console.WriteLine("Net Salary {0}", netSalary);
        }
    }
    public class TaxCalculator
    {
        public int Salary { getset; }
        public int TaxOffset { getset; }
        public int NetPay { getset; }
 
        public TaxCalculator GrossSalary(int salary)
        {
            Salary = Salary;
            return this;
        }
        public TaxCalculator CalculateSalary(int taxOffset)
        {
            TaxOffset = taxOffset;
            Salary -= TaxOffset;
            return this;
        }
        public string TotalNetPay(int super)
        {
            Salary -= super;
            return Salary.ToString();
        }
    }
}

Output of the program is as below,

Net Salary -110
Press any key to continue . . .


thanks mohammad.