private static bool IsMatch(PersonKey searchFor, PersonNode searchIn)
        {
            var searchInPerson = searchIn.Person;

            if (!IsMatch(searchFor.FirstName, searchInPerson.FirstName))
            {
                return(false);
            }
            else if (!IsMatch(searchFor.MiddleName, searchInPerson.MiddleName))
            {
                return(false);
            }
            else if (!IsMatch(searchFor.LastName, searchInPerson.LastName))
            {
                return(false);
            }
            else
            {
                var isMatch = IsMatch(searchFor.BirthYear, searchInPerson.BirthYear);

                return(isMatch);
            }
        }
Beispiel #2
0
 set => SetValue(PersonKey, value);
Beispiel #3
0
        public void Add_does_not_throw_for_adding_null(PersonKey key)
        {
            var sut = GetSut();

            Assert.That(() => sut.Add(key, null), Throws.Nothing);
        }
 public int CompareTo(PersonKey pk)
 {
     return(_keyString.CompareTo(pk._keyString));
 }
Beispiel #5
0
 public void Post([FromBody] PersonKey value)
 {
     personKeyDataRepository.Test(value);
 }
Beispiel #6
0
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 103;
            long[] Pids      = new long[BatchCount];
            int    PidsIndex = 0;

            PersonKey[] pk  = new PersonKey[BatchCount];
            int         Ctr = 0;

            do
            {
                Ctr++;
                pk[PidsIndex++] = PeopleStoreByName.CurrentKey;
                if (PidsIndex == BatchCount)
                {
                    QueryResult <PersonKey>[] PeopleIDs;
                    if (PeopleStoreByName.Query(QueryExpression <PersonKey> .Package(pk), out PeopleIDs))
                    {
                        for (int i = 0; i < PeopleIDs.Length; i++)
                        {
                            Pids[i] = (long)PeopleIDs[i].Value;
                        }

                        QueryResult <long>[] PeopleFound;
                        if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out PeopleFound))
                        {
                            long[] Aids = new long[PidsIndex];
                            int    i    = 0;
                            foreach (QueryResult <long> pf in PeopleFound)
                            {
                                if (pf.Found)
                                {
                                    Aids[i++] = ((Person)pf.Value).AddressID;
                                }
                            }
                            QueryResult <long>[] AddressesFound;
                            if (AddressStore.Query(QueryExpression <long> .Package(Aids), out AddressesFound))
                            {
                                //** process found Address records here...
                                int ctr2 = 0;
                                foreach (var a in AddressesFound)
                                {
                                    ctr2++;
                                    if (!a.Found)
                                    {
                                        Console.WriteLine("Failed to read {0}.", a.Key);
                                    }
                                }
                                if (ctr2 != 1000)
                                {
                                    Console.WriteLine("Failed to read 1000 records, 'only read {0}.", ctr2);
                                }
                            }
                        }
                    }
                    PidsIndex = 0;
                }
            } while (PeopleStoreByName.MoveNext());

            if (Ctr != PeopleStore.Count)
            {
                Console.WriteLine("Failed! Read {0}, expected {1}", Ctr * 4, PeopleStore.Count * 4);
            }
            else
            {
                Console.WriteLine("Read {0} items.", Ctr * 4);
            }
        }
Beispiel #7
0
 public PersonEntry(PersonKey key, int level)
 {
     this.key     = key;
     this.level   = level;
     this.friends = new List <PersonFriend>();
 }
Beispiel #8
0
        public void RunTest()
        {
            const string name1 = "Henry has a first name!";
            const string name2 = "Larry doesn't have a last name!";
            var          key1  = new PersonKey(Guid.NewGuid(), name1);
            var          key2  = new PersonKey(Guid.NewGuid(), name2);

            var personEntry1 = new PersonEntry(key1, 10);
            var personEntry2 = new PersonEntry(key2, 5);

            personEntry1.Friends.Add(new PersonFriend(0xAEF8329dF, "Mark"));
            personEntry2.Friends.Add(new PersonFriend(0xF8372D33F, "Henry"));
            personEntry2.Friends.Add(new PersonFriend(0x47928C3ED, "Jane"));

            var thresholdsByKey = new Dictionary <PersonKey, int>();

            thresholdsByKey.Add(key1, 30);
            thresholdsByKey.Add(key2, 2);

            var levelRemovalProcessor   = new RemovalByLevelThresholdProcessor(thresholdsByKey);
            var friendClearingProcessor = new FriendClearingProcessor();

            var serializer = new PofSerializer(context);

            using (var ms = new MemoryStream()) {
                using (var writer = new BinaryWriter(ms, Encoding.UTF8, true)) {
                    serializer.Serialize(writer, levelRemovalProcessor);
                    serializer.Serialize(writer, friendClearingProcessor);
                }
                ms.Position = 0;
                Console.WriteLine(ms.ToArray().ToHex());
                using (var reader = new BinaryReader(ms, Encoding.UTF8, true)) {
                    levelRemovalProcessor   = serializer.Deserialize <RemovalByLevelThresholdProcessor>(reader);
                    friendClearingProcessor = serializer.Deserialize <FriendClearingProcessor>(reader);
                }
            }

            var entry1         = new Entry <PersonKey, PersonEntry>(key1, personEntry1);
            var entry2         = new Entry <PersonKey, PersonEntry>(key2, personEntry2);
            var originalEntry1 = entry1;
            var originalEntry2 = entry2;

            using (var ms = new MemoryStream()) {
                using (var writer = new BinaryWriter(ms, Encoding.UTF8, true)) {
                    serializer.Serialize(writer, entry1);
                    serializer.Serialize(writer, entry2);
                }
                ms.Position = 0;
                Console.WriteLine(ms.ToArray().ToHex());
                using (var reader = new BinaryReader(ms, Encoding.UTF8, true)) {
                    entry1 = serializer.Deserialize <Entry <PersonKey, PersonEntry> >(reader);

                    int frameLength = reader.ReadInt32();
                    var frameBody   = reader.ReadBytes(frameLength);
                    using (var innerMs = new MemoryStream(frameBody))
                        using (var innerReader = new BinaryReader(innerMs, Encoding.UTF8, true)) {
                            entry2 = (Entry <PersonKey, PersonEntry>)serializer.Deserialize(innerReader, SerializationFlags.Lengthless, null);
                        }
                }
            }

            friendClearingProcessor.Process(entry1);
            friendClearingProcessor.Process(entry2);

            levelRemovalProcessor.Process(entry1);
            levelRemovalProcessor.Process(entry2);

            AssertTrue(entry1.IsPresent());
            AssertFalse(entry2.IsPresent());

            using (var ms = new MemoryStream()) {
                using (var writer = new BinaryWriter(ms, Encoding.UTF8, true)) {
                    serializer.Serialize(writer, entry1);
                    serializer.Serialize(writer, entry2);
                }
                ms.Position = 0;
                Console.WriteLine(ms.ToArray().ToHex());
                using (var reader = new BinaryReader(ms, Encoding.UTF8, true)) {
                    entry1 = serializer.Deserialize <Entry <PersonKey, PersonEntry> >(reader);
                    entry2 = serializer.Deserialize <Entry <PersonKey, PersonEntry> >(reader);
                }
            }

            AssertTrue(entry1.IsPresent());
            AssertFalse(entry2.IsPresent());
        }