Beispiel #1
0
        }         // constructor

        public StringDifference this[string alice, string boob] {
            get {
                NormalStringPair tpl = Normalize(alice, boob);

                if (tpl.AreEqual)
                {
                    return(StringDifference.Equal);
                }

                if (diffMap.ContainsKey(tpl.Alice))
                {
                    SortedDictionary <string, StringDifference> nameMap = this.diffMap[tpl.Alice];

                    if (nameMap.ContainsKey(tpl.Boob))
                    {
                        return(nameMap[tpl.Boob]);
                    }
                }                 // if

                return(StringDifference.NotEqual);
            }     // get
        }         // indexer
Beispiel #2
0
        }         // indexer

        private void Load(Name customerName, List <Name> directorNames, AConnection db)
        {
            var firstNames = new SortedSet <string>();
            var lastNames  = new SortedSet <string>();

            foreach (Name name in directorNames)
            {
                string s = Normalize(name.FirstName);

                if (s != string.Empty)
                {
                    firstNames.Add(s);
                }

                s = Normalize(name.LastName);

                if (s != string.Empty)
                {
                    lastNames.Add(s);
                }
            }             // for each

            diffMap.Clear();

            if ((firstNames.Count == 0) && (lastNames.Count == 0))
            {
                return;
            }

            db.ForEachRowSafe(
                sr => {
                NormalStringPair tpl = Normalize(sr["Alice"], sr["Boob"]);

                if (tpl.AreEqual)
                {
                    return;
                }

                int mark = sr["Mark"];

                StringDifference diff = Enum.IsDefined(typeof(StringDifference), mark)
                                                ? (StringDifference)mark
                                                : StringDifference.NotEqual;

                SortedDictionary <string, StringDifference> nameMap = this.diffMap.ContainsKey(tpl.Alice)
                                                ? this.diffMap[tpl.Alice]
                                                : null;

                if (nameMap == null)
                {
                    this.diffMap[tpl.Alice] = new SortedDictionary <string, StringDifference> {
                        { tpl.Boob, diff }
                    }
                }
                ;
                else
                {
                    nameMap[tpl.Boob] = diff;
                }
            },
                "GetNameDifference",
                CommandSpecies.StoredProcedure,
                new QueryParameter("FirstName", Normalize(customerName.FirstName)),
                new QueryParameter("LastName", Normalize(customerName.LastName)),
                db.CreateTableParameter <string>("FirstNames", firstNames),
                db.CreateTableParameter <string>("LastNames", lastNames)
                );
        }         // Load