static void DictMethodSample() { Person p = new Person() { LastName = "TORRES", FirstName = "Frederic", BirthDay = new DateTime(1964,12, 11) }; foreach(var k in p.Dict()){ Console.WriteLine("{0}='{1}'", k.Key, k.Value); } }
static void FormatMethodSample() { var firstName = "Fred"; var age = 45; var s1 = String.Format("firstName:{0}, age:{1}", firstName, age); // Dynamic Sugar Syntax var s2 = "firstName:{firstName}, age:{age}".Template(new { firstName, age }); Console.WriteLine(s1); Console.WriteLine(s2); Person p = new Person() { LastName = "TORRES" , FirstName = "Frederic", BirthDay = new DateTime(1964,12, 11), DrivingLicenses = DS.List("Car", "Moto Bike") }; //DrivingLicenses = new List<string>() { "Car", "Moto Bike" } Console.WriteLine( // Call 3 properties in the FormatString p.Format("FullName:'{LastName},{FirstName}', BirthDay:{BirthDay:MM/dd/yyyy}, DrivingLicenses:{DrivingLicenses}") ); Console.WriteLine( // Call a method in the FormatString p.Format("LoadInformation:{LoadInformation()} ") ); }
static void In() { int i = 1; if(i.In(1,2,3)){ } List<int> l = DS.List(1,2,3); if(i.In(l)){ } var state = "good"; if(state.In("good","bad","soso")){ } var customerType = CustomerType.Good; if(customerType.In(CustomerType.Good, CustomerType.SoSo)){ } var people = DS.List( new Person() { LastName = "Descartes", FirstName = "Rene", BirthDay = new DateTime(1596,3,31)}, new Person() { LastName = "Montesquieu", FirstName = "Charles-Louis", BirthDay = new DateTime(1689,1,18)}, new Person() { LastName = "Rousseau", FirstName = "JJ", BirthDay = new DateTime(1712,3,31)} ); var Descartes = new Person() { LastName = "Descartes", FirstName = "Rene", BirthDay = new DateTime(1596,3,31)}; if(Descartes.In(people)){ Console.WriteLine("In the list people"); } else{ Console.WriteLine("Not in the list people"); } }