Ejemplo n.º 1
0
        public Person CreateInstance(Observation observation)
        {
            string key = GetPersonKeyFor(observation);

            if (peopleCache.ContainsKey(key)) {
                return peopleCache[key];
            }
            else {
                string country = observation.Country;
                string personId = observation.PersonId;
                Person person = new Person(country, personId);
                peopleCache[key] = person;
                return person;
            }
        }
Ejemplo n.º 2
0
        private void Validate(Observation o, int index)
        {
            if (string.IsNullOrWhiteSpace(o.Country)) {
                string errorMessage = string.Format("line ({0}): Country is missing", index);
                AddError(errorMessage);
            }

            if (string.IsNullOrWhiteSpace(o.PersonId)) {
                string errorMessage = string.Format("line ({0}): PersonId is missing", index);
                AddError(errorMessage);
            }
        }
Ejemplo n.º 3
0
 private string GetPersonKeyFor(Observation observation)
 {
     return string.Format("{0}_{1}", observation.PersonId, observation.Country);
 }