示例#1
0
        static void Main(string[] args)
        {
            var converter = WombatConverter.CreateInitialized();

            int    number         = converter.Convert <string, int>("923");
            string numbetToString = converter.Convert(number, string.Empty);

            Console.WriteLine(number);
            Console.WriteLine(numbetToString);


            converter = WombatConverter.CreateEmpty();

            converter.Register <FirstClass, SecondClass>(
                firstClass =>
            {
                return(new SecondClass
                {
                    Age = firstClass.Age,
                    NameAndAge = string.Format("{0} are {1} years old",
                                               firstClass.Name, firstClass.Age)
                });
            });

            SecondClass secondClass =
                converter.Convert <FirstClass, SecondClass>(new FirstClass {
                Age = 11, Name = "John"
            });

            Console.WriteLine("Age: " + secondClass.Age);
            Console.WriteLine("NameAndAge: " + secondClass.NameAndAge);
            Console.ReadKey();
        }
示例#2
0
 public void SetUp()
 {
     this.target = WombatConverter.CreateInitialized();
 }