private static bool CompareNames(string name1, string name2, NameComparison comparison)
        {
            switch (comparison)
            {
            case NameComparison.None:
                return(true);

            case NameComparison.CaseSensitive:
                return(StringComparer.Ordinal.Equals(name1, name2));

            case NameComparison.CaseInsensitive:
                return(StringComparer.OrdinalIgnoreCase.Equals(name1, name2));

            default:
                throw new InvalidEnumArgumentException(nameof(comparison), (int)comparison, typeof(NameComparison));
            }
        }
        private void CheckNames()
        {
            Message("Starting Name Check");
            NameComparison n = new NameComparison();

            var results = n.Compare(WorkingCopyBaseline, WorkingCopyDelta);

            //update working copies as we go with those still yet to resolve
            WorkingCopyBaseline.Clear(); WorkingCopyDelta.Clear();

            foreach (var item in results.Where(x => x.Value == ChangeType.Matched))
            {
                Message(String.Format("Found a Match for type {1} with Name: {0}", item.Key.Name, item.Key.GetType().ToString()));
                EntityLabelChanges[item.Key] = item.Value;
            }
            foreach (var item in results.Where(x => x.Value == ChangeType.Added))
            {
                WorkingCopyDelta.Add(item.Key);
                Message(String.Format("Found a new item of type {1} with Name: {0}", item.Key.Name, item.Key.GetType().ToString()));
                EntityLabelChanges[item.Key] = item.Value;
            }
            foreach (var item in results.Where(x => x.Value == ChangeType.Deleted))
            {
                WorkingCopyBaseline.Add(item.Key);
                Message(String.Format("Found a missing item of type {1} with Name: {0}", item.Key.Name, item.Key.GetType().ToString()));
                EntityLabelChanges[item.Key] = item.Value;
            }
            foreach (var item in results.Where(x => x.Value == ChangeType.Unknown))
            {
                WorkingCopyBaseline.Add(item.Key);
                Message(String.Format("Found duplicate possibilities for item of type {1} with Name: {0}", item.Key.Name, item.Key.GetType().ToString()));
                EntityLabelChanges[item.Key] = item.Value;
            }

            var m = n.GetMap();

            foreach (var key in m)
            {
                EntityMapping[key.Key] = m[key.Key];
            }

            Message("Name Check - Complete");
        }
Exemple #3
0
 public Result <NameSelection> Compare(string name1, string name2, NameComparison comparison)
 => MustBeKnown(name1, nameof(name1))
 | (m => m.MustBeKnown(name2, nameof(name2)))
 | (m => m.MustBeDifferent(name1, name2))
 | (m => comparison switch
 {