Пример #1
0
        private bool IsEqual(DeviceIdentifier a, DeviceIdentifier b, DeviceStringsComparer comparerInstance)
        {
            var pidMatch    = a.VendorID == b.VendorID && a.ProductID == b.ProductID;
            var stringMatch = !a.DeviceStrings.Any() || !b.DeviceStrings.Any() || a.DeviceStrings.SequenceEqual(b.DeviceStrings, comparerInstance);
            var inputMatch  = a.InputReportLength == b.InputReportLength || a.InputReportLength is null || b.InputReportLength is null;
            var outputMatch = a.OutputReportLength == b.OutputReportLength || a.OutputReportLength is null || b.OutputReportLength is null;

            return(pidMatch && stringMatch && inputMatch && outputMatch);
        }
Пример #2
0
        public void Configurations_DeviceIdentifier_IsNotConflicting(IdentificationContext deviceIdentifier, IdentificationContext otherIdentifier)
        {
            var comparer = new DeviceStringsComparer();

            var equality = IsEqual(deviceIdentifier.Identifier, otherIdentifier.Identifier, comparer);

            if (equality)
            {
                var message = string.Format("'{0}' {1} (index: {2}) conflicts with '{3}' {4} (index: {5})",
                                            deviceIdentifier.TabletConfiguration.Name,
                                            deviceIdentifier.IdentifierType,
                                            deviceIdentifier.IdentifierIndex,
                                            otherIdentifier.TabletConfiguration.Name,
                                            otherIdentifier.IdentifierType,
                                            otherIdentifier.IdentifierIndex);

                throw new Exception(message);
            }
        }