Mitigated chapter 12 having a dependency on a ch8 removed listing
Listing 08.11 is no longer in the book. Chapter 12.43 was using it.
MODIFY
src/Chapter12/Listing12.43.CovarianceUsingTheOutTypeParameterModifier.cs
src/Chapter12/Listing12.43.CovarianceUsingTheOutTypeParameterModifier.cs
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_43
{
using Chapter08.Listing08_02;
- using Contact = Chapter08.Listing08_11.Contact;
+ using Contact = Chapter12.Listing12_43_Dependencies.Contact;
interface IReadOnlyPair<out T>
{
@@ -86,4 +86,79 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_43
PdaItem pdaItem2 = pair.Second;
}
}
+
+}
+
+
+//Dependencies
+namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter12.Listing12_43_Dependencies
+{
+ using Chapter08.Listing08_02;
+ using System;
+
+ interface IPerson
+ {
+ string FirstName
+ {
+ get;
+ set;
+ }
+
+ string LastName
+ {
+ get;
+ set;
+ }
+ }
+
+ public class Person : IPerson
+ {
+ public Person(string firstName, string lastName)
+ {
+ FirstName = firstName;
+ LastName = lastName;
+ }
+ public string? _FirstName;
+ public string FirstName
+ {
+ get => _FirstName!;
+ set => _FirstName = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ public string? _LastName;
+ public string LastName
+ {
+ get => _LastName!;
+ set => _LastName = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ public class Contact : PdaItem, IPerson
+ {
+ public Contact(string name)
+ : base(name)
+ {
+ }
+
+ private Person Person
+ {
+ get { return _Person!; }
+ set { _Person = value ?? throw new ArgumentNullException(nameof(value)); }
+ }
+ private Person? _Person;
+
+ public string FirstName
+ {
+ get { return Person.FirstName; }
+ set { Person.FirstName = value; }
+ }
+
+ public string LastName
+ {
+ get { return Person.LastName; }
+ set { Person.LastName = value; }
+ }
+
+ // ...
+ }
+
}

Mitigated chapter 12 having a dependency on a ch8 removed listing

Listing 08.11 is no longer in the book. Chapter 12.43 was using it.