Esempio n. 1
0
        /// <summary>
        /// Construct the comparison object that we'll be using for this current run. Once
        /// we have it, we need only call the `Run` method on the result.
        /// </summary>
        /// <param name="fromRequest"><see cref="ComparisonRequest"/>: The representation of the current request.</param>
        /// <param name="withOptions"><see cref="ComparisonOptions"/>: The options that will be used for the request.</param>
        /// <returns>The comparison object, that will handle the current request.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Throws if we get a <see cref="ComparisonWith"/>
        /// value that isn't recognized.</exception>
        public ICompareImages Construct(ComparisonRequest fromRequest, ComparisonOptions withOptions)
        {
            ICompareImages imageComparer;

            switch (fromRequest.With)
            {
            case ComparisonWith.All:
                imageComparer = new DirectoryComparison(
                    new BasicHashProvider(),
                    new HashComparison(withOptions.BiasPercent),
                    withOptions);
                break;

            case ComparisonWith.Pair:
                imageComparer = new PairComparison(
                    new BasicHashProvider(),
                    new PixelComparison(withOptions),
                    withOptions);
                break;

            case ComparisonWith.Single:
                imageComparer = new SingleComparison(
                    new BasicHashProvider(),
                    new HashComparison(withOptions.BiasPercent),
                    withOptions);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(imageComparer);
        }
Esempio n. 2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region Private Constructors
        private Pair()
        {
            this.comparisonType   = PairComparison.None;
            this.comparer         = null;
            this.equalityComparer = null;
            this.throwOnError     = false;
        }
Esempio n. 3
0
            public static void CompareVolumes(Volumes oldvols, Volumes newvols, out List <Volume> removed, out List <Volume> added, out List <Volume[]> changed)
            {
                IEnumerator <Volume> enumold = ((IEnumerable <Volume>)oldvols).GetEnumerator();
                IEnumerator <Volume> enumnew = ((IEnumerable <Volume>)oldvols).GetEnumerator();

                PairComparison.Compare(enumold, enumnew, out removed, out added, out changed);
            }
Esempio n. 4
0
        ///////////////////////////////////////////////////////////////////////

        #region Public Constructors
        public AnyPair(
            PairComparison comparisonType,
            bool throwOnError
            )
            : this()
        {
            this.comparisonType = comparisonType;
            this.throwOnError   = throwOnError;
        }
Esempio n. 5
0
        ///////////////////////////////////////////////////////////////////////

        #region Private Constructors
        private AnyPair()
        {
            this.comparisonType    = PairComparison.None;
            this.xComparer         = null;
            this.xEqualityComparer = null;
            this.yComparer         = null;
            this.yEqualityComparer = null;
            this.formatProvider    = null;
            this.throwOnError      = false;
        }
Esempio n. 6
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public Pair(
            PairComparison comparisonType,
            IComparer <T> comparer,
            IEqualityComparer <T> equalityComparer,
            bool throwOnError
            )
            : this(comparisonType, throwOnError)
        {
            this.comparer         = comparer;
            this.equalityComparer = equalityComparer;
        }
Esempio n. 7
0
                public static void Compare(IEnumerator <Volume> enumold, IEnumerator <Volume> enumnew, out List <Volume> removed, out List <Volume> added, out List <Volume[]> changed)
                {
                    removed = new List <Volume>();
                    added   = new List <Volume>();
                    changed = new List <Volume[]>();
                    PairComparison pc = new PairComparison()
                    {
                        enumnew = enumnew, enumold = enumold, removed = removed, added = added, changed = changed
                    };

                    pc.compare();
                }
Esempio n. 8
0
        ///////////////////////////////////////////////////////////////////////

        public AnyPair(
            PairComparison comparisonType,
            IComparer <T1> xComparer,
            IEqualityComparer <T1> xEqualityComparer,
            IComparer <T2> yComparer,
            IEqualityComparer <T2> yEqualityComparer,
            IFormatProvider formatProvider,
            bool throwOnError
            )
            : this(comparisonType, throwOnError)
        {
            this.xComparer         = xComparer;
            this.xEqualityComparer = xEqualityComparer;
            this.yComparer         = yComparer;
            this.yEqualityComparer = yEqualityComparer;
            this.formatProvider    = formatProvider;
        }