Example #1
0
        private static void BigSetIsByIdentity()
        {
            using (IObjectContainer container = OpenDatabase())
            {
                City city = container.Query<City>()[0];

                // #example: Note that the big-set compares by identity, not by equality
                Person aCitizen;
                using (IEnumerator<Person> aCitizenEnumerator = city.Citizen.GetEnumerator())
                {
                    aCitizenEnumerator.MoveNext();
                    aCitizen = aCitizenEnumerator.Current;
                }
                Console.WriteLine("The big-set uses the identity, not equality of an object");
                Console.WriteLine("Therefore it .contains() on the same person-object is "
                                  + city.Citizen.Contains(aCitizen));
                Person equalPerson = new Person(aCitizen.Name);
                Console.WriteLine("Therefore it .contains() on a equal person-object is "
                                  + city.Citizen.Contains(equalPerson));
                // #end example
            }
        }
Example #2
0
 public bool IsCitizen(Person person)
 {
     return citizen.Contains(person);
 }
Example #3
0
 public bool Equals(Person other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.name, name);
 }
Example #4
0
 private static void PrintCitizenStatus(City city, Person aPerson)
 {
     if (city.IsCitizen(aPerson))
     {
         Console.WriteLine(aPerson + " is a citizen");
     }
     else
     {
         Console.WriteLine(aPerson + " isn't a citizen");
     }
 }