コード例 #1
0
        public override void Run()
        {
            var unrelatedObject = new LooksLikeAnEntity()
            {
                Id   = 42,
                Name = "Douglas Adams"
            };

            var ducked = unrelatedObject.DuckAs <IReadOnlyEntity>();

            Log("Original:\n", unrelatedObject, "\nDucked:\n", ducked);
        }
コード例 #2
0
        public override void Run()
        {
            var unrelatedObject = new LooksLikeAnEntity()
            {
                Id   = 42,
                Name = "John Carmack"
            };
            var ducked = unrelatedObject.DuckAs <IReadWriteEntity>();

            Log("Before:\n", ducked);

            // Ada Lovelace came before all the great female programmers!
            ducked.Id   = 0;
            ducked.Name = "Ada Lovelace";

            Log("After:\n", ducked);
            Log("After, original POCO:\n", unrelatedObject);
        }