コード例 #1
0
        static void Main(string[] args)
        {
            //var hello = "hello";
            //var sb = new HtmlBuilder("ul");
            //sb.Addchild("li", "Hello").Addchild("li", "Payam");
            //Console.WriteLine(sb.ToString());

            Person person = new Person();

            person.Name     = "Payam";
            person.LastName = "Shoghi";
            person.Position = "Software Engineer";

            var me = Person.New.Called("Payam").WorksAsA("Fortis").Build();

            Console.WriteLine(me);

            Console.WriteLine("functional approach");
            var fme     = new FuncPersonBuilder();
            var builtMe = fme.Called("Payam").WorksAs("Developer").Build();

            Console.WriteLine($"{builtMe.Name} works as {builtMe.Position}");

            Console.WriteLine("Faceted Person Building");
            var fpb   = new FPersonBuilder();
            var meFpb = fpb.works.At("Fortis")
                        .AsA("Engineer")
                        .EarningIntAmount(150000)
                        .lives.At("946 BushWick Ave")
                        .In("NY City").WithPostcode("11221");
            var pm = (FacetedPerson)meFpb;

            Console.WriteLine(pm.ToString());
        }
コード例 #2
0
 public static FuncPersonBuilder WorksAs(this FuncPersonBuilder personBuilder, string position)
 {
     return(personBuilder.Do(p => p.Position = position));
 }