//******************************************************
        //CompareTo
        //******************************************************
        /// <summary>
        ///    <para>Compares this object to another, based on specified options.</para>
        /// </summary>
        /// <param name='otherObject'>The object to which to compare this object. </param>
        /// <param name='settings'>Options on how to compare the objects. </param>
        /// <returns>
        /// <para><see langword='true'/> if the objects compared are equal
        ///    according to the given options; otherwise, <see langword='false'/>
        ///    .</para>
        /// </returns>
        public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
        {
            if (null == otherObject)
            {
                throw new ArgumentNullException(nameof(otherObject));
            }

            bool result = false;

            if (null != wbemObject)
            {
                int status = (int)ManagementStatus.NoError;

                status = wbemObject.CompareTo_((int)settings, otherObject.wbemObject);

                if ((int)ManagementStatus.Different == status)
                {
                    result = false;
                }
                else if ((int)ManagementStatus.NoError == status)
                {
                    result = true;
                }
                else if ((status & 0xfffff000) == 0x80041000)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                }
                else if (status < 0)
                {
                    Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                }
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Comparers <paramref name="obj1"/> and <paramref name="obj2"/>.
        /// </summary>
        /// <param name="obj1">Object 1.</param>
        /// <param name="obj2">Object 2.</param>
        /// <param name="settings">Instance of <see cref="ComparisonSettings"/> class.</param>
        /// <returns>true if the objects are considered equal; otherwise, false.</returns>
        public bool Compare(object obj1, object obj2, ComparisonSettings settings)
        {
            var isObj1Default = obj1?.Equals(_defaultValue) != false || obj1.Equals(_typeDefaultValue);
            var isObj2Default = obj2?.Equals(_defaultValue) != false || obj2.Equals(_typeDefaultValue);

            return((isObj1Default && isObj2Default) || _valueComparer.Compare(obj1, obj2, settings));
        }
        public void OverrideString()
        {
            var b1 = new TestClassB
            {
                B      = "B",
                ClassA = new TestClassA
                {
                    A = "A"
                }
            };

            var b2 = new TestClassB
            {
                B      = "b",
                ClassA = new TestClassA
                {
                    A = "a"
                }
            };

            var settings = new ComparisonSettings();
            var factory  = new MyComparersFactory();

            var comparer = factory.GetObjectsComparer <TestClassB>(settings);

            var isEqual = comparer.Compare(b1, b2);

            Assert.IsTrue(isEqual);
        }
        public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
        {
            if (otherObject == null)
            {
                throw new ArgumentNullException("otherObject");
            }
            bool flag = false;

            if (this.wbemObject != null)
            {
                int errorCode = 0;
                errorCode = this.wbemObject.CompareTo_((int)settings, otherObject.wbemObject);
                if (0x40003 == errorCode)
                {
                    return(false);
                }
                if (errorCode == 0)
                {
                    return(true);
                }
                if ((errorCode & 0xfffff000L) == 0x80041000L)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
                    return(flag);
                }
                if (errorCode < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode);
                }
            }
            return(flag);
        }
        private ComparisonSettings GetSettings()
        {
            ComparisonSettings settings;

            settings = new ComparisonSettings();

            //Extract comparison mode setting.
            if (CompareZygosityRadioButton.Checked)
            {
                settings.Mode = InvestigationMode.Zygosity;
            }
            else if (CompareGenotypesRadioButton.Checked)
            {
                settings.Mode = InvestigationMode.Genotype;
            }
            else if (CompareFreeTextRadioButton.Checked)
            {
                settings.Mode = InvestigationMode.FreeText;
            }
            settings.HarmonizePolarities     = ConvertPolarityCheckBox.Checked;
            settings.IsFreeTextCaseSensitive = CaseSensitiveCheckBox.Checked;

            //Extract list settings.
            settings.ListUnharmonizableSNPs = ListUnharmonizableCheckBox.Checked;
            settings.ListCompared           = ListComparedCheckBox.Checked;
            settings.ListDifferent          = ListDifferentCheckBox.Checked;
            settings.ListDuplicateFailures  = ListDuplicateFailuresCheckBox.Checked;
            settings.ListIdentical          = ListIdenticalCheckBox.Checked;
            settings.ListMissing            = ListMissingCheckBox.Checked;
            settings.ListNoResults          = ListMissingValueCheckBox.Checked;
            settings.ListInvalid            = ListInvalidAllelesCheckBox.Checked;

            return(settings);
        }
        public void WronkType()
        {
            var settings = new ComparisonSettings();

            settings.SetCustomSetting(123, "setting1");

            Assert.Throws <KeyNotFoundException>(() => settings.GetCustomSetting <double>("setting1"));
        }
        public void WronkKey()
        {
            var settings = new ComparisonSettings();

            settings.SetCustomSetting(123, "setting1");

            Assert.Throws <KeyNotFoundException>(() => settings.GetCustomSetting <int>("wrongSettingKey"));
        }
Example #8
0
        public void PopulateFileList(ComparisonSettings settings)
        {
            // get left side list of files
            _leftSideFiles = GetFileList(settings.PathToCheckLeft).OrderBy(f => f.FullName).ToList().AsReadOnly();

            // get right side list of files
            _rightSideFiles = GetFileList(settings.PathToCheckRight).OrderBy(f => f.FullName).ToList().AsReadOnly();
        }
Example #9
0
        public void GetObjectsComparerGeneric()
        {
            var settings = new ComparisonSettings();
            var factory  = new ComparersFactory();

            var comparer = factory.GetObjectsComparer <string>(settings);

            Assert.AreEqual(settings, comparer.Settings);
        }
Example #10
0
        public void GetObjectsComparer()
        {
            var settings = new ComparisonSettings();
            var factory  = new ComparersFactory();

            var comparer = factory.GetObjectsComparer(typeof(string), settings);

            Assert.AreEqual(settings, comparer.Settings);
        }
Example #11
0
        public void Run(ComparisonSettings settings)
        {
            LogTo.Info("Running Bootstrapper");

            RegisterServices();

            // register the main program so the contain will build it up for us
            _container.Register <IFileCheckerMain, FileCheckerMain>(Lifestyle.Singleton);
        }
Example #12
0
            public override IComparer <T> GetObjectsComparer <T>(ComparisonSettings settings = null, BaseComparer parentComparer = null)
            {
                if (typeof(T) == typeof(B))
                {
                    return((IComparer <T>)_comparerB);
                }

                return(base.GetObjectsComparer <T>(settings, parentComparer));
            }
Example #13
0
        /// <summary>
        /// Comparers <paramref name="obj1"/> and <paramref name="obj2"/>.
        /// </summary>
        /// <param name="obj1">Object 1.</param>
        /// <param name="obj2">Object 2.</param>
        /// <param name="settings">Instance of <see cref="ComparisonSettings"/> class.</param>
        /// <returns>true if the objects are considered equal; otherwise, false.</returns>
        public bool Compare(object obj1, object obj2, ComparisonSettings settings)
        {
            if (obj1 == null || obj2 == null)
            {
                return(obj1 == obj2);
            }

            return(obj1.Equals(obj2));
        }
        public void SetgetCustomSettingWithoutKey()
        {
            var settings = new ComparisonSettings();

            settings.SetCustomSetting("test string");

            var settingValue = settings.GetCustomSetting <string>();

            Assert.AreEqual("test string", settingValue);
        }
Example #15
0
        public static void Main(string[] args)
        {
            InitLogging();

            // Check the arguments, before we do anything else - bail out with error message if they're bad
            var validator        = new ProgramArgumentsValidator();
            var validationResult = validator.ValidateArgs(args);

            if (validationResult.IsValid == false)
            {
                Console.WriteLine(validationResult.Message);
                PromptForClose();
                return;
            }

            // load the config file we got from the command line and validate it's good
            var settings = LoadSettingsFromSettingsFile(args, new ProgramArgumentsParser(validator), new JsonSettingsLoader());

            // setup the output(s) as required by the args so we can output the results of the validation
            var outputService = SetupOutputService(settings);

            var settingsValidationResult = ComparisonSettings.Validate(settings);

            if (settingsValidationResult.IsValid == false)
            {
                Console.WriteLine(settingsValidationResult.Message);
                outputService.OutputError(settingsValidationResult.Message);
                PromptForClose();
                return;
            }


            // Create a new Simple Injector container
            var container = new Container();

            // pass it into the boostrapper for population and populate it!
            var bootstrapper = new Bootstrapper(container);

            bootstrapper.Run(settings);

            // Let's get to work
            var mainRunner = bootstrapper.GetMainRunner();

            try
            {
                mainRunner.RunFileCheck(settings, outputService);
            }
            catch (Exception ex)
            {
                LogTo.FatalException("Exception!", ex);
                outputService.OutputError(ex.Message);
            }

            PromptForClose();
        }
 public void OutputResults(ComparisonResults comparisonResults, ComparisonSettings settings)
 {
     foreach (var outputter in _outputters)
     {
         outputter.RemoveExistingResults();
         outputter.AddTitle("Produced at: " + _timeStampService.GetTimeStamp());
         outputter.OutputFileContentDiffs(comparisonResults.FilePairs, settings.OnlyShowDiffs, "File Comparsion");
         outputter.OutputFolderDiffs(comparisonResults.FilesOnlyInLeft, "Files Missing From Right (" + settings.PathToCheckRight + ")");
         outputter.OutputFolderDiffs(comparisonResults.FilesOnlyInRight, "Files Missing From Left (" + settings.PathToCheckLeft + ")");
     }
 }
            public override IComparer <T> GetObjectsComparer <T>(ComparisonSettings settings = null,
                                                                 BaseComparer parentComparer = null)
            {
                IComparer <T> comparer = base.GetObjectsComparer <T>(settings, parentComparer);

                if (parentComparer == null)
                {
                    comparer.AddComparerOverride(typeof(string), new IgnoreCaseStringsValueComparer());
                }

                return(comparer);
            }
Example #18
0
        public override IComparer <T> GetObjectsComparer <T>(ComparisonSettings settings = null,
                                                             BaseComparer parentComparer = null)
        {
            if (typeof(T) != typeof(IList <FormulaItem>))
            {
                return(base.GetObjectsComparer <T>(settings, parentComparer));
            }

            var comparer = new CustomFormulaItemsComparer(settings, parentComparer, this);

            return((IComparer <T>)comparer);
        }
        public void SetgetCustomSettingWithKey()
        {
            var settings = new ComparisonSettings();

            settings.SetCustomSetting(123, "setting1");
            settings.SetCustomSetting(234, "setting2");

            var setting1Value = settings.GetCustomSetting <int>("setting1");
            var setting2Value = settings.GetCustomSetting <int>("setting2");

            Assert.AreEqual(123, setting1Value);
            Assert.AreEqual(234, setting2Value);
        }
Example #20
0
        /// <summary>
        /// Comparers <paramref name="obj1"/> and <paramref name="obj2"/>.
        /// </summary>
        /// <param name="obj1">Object 1.</param>
        /// <param name="obj2">Object 2.</param>
        /// <param name="settings">Instance of <see cref="ComparisonSettings"/> class.</param>
        /// <returns>true if the objects are considered equal; otherwise, false.</returns>
        public override bool Compare(string obj1, string obj2, ComparisonSettings settings)
        {
            if (obj1 == null)
            {
                obj1 = string.Empty;
            }

            if (obj2 == null)
            {
                obj2 = string.Empty;
            }

            return(obj1.Equals(obj2));
        }
Example #21
0
        /// <summary>
        /// Comparers <paramref name="obj1"/> and <paramref name="obj2"/>.
        /// </summary>
        /// <param name="obj1">Object 1.</param>
        /// <param name="obj2">Object 2.</param>
        /// <param name="settings">Instance of <see cref="ComparisonSettings"/> class.</param>
        /// <returns>true if the objects are considered equal; otherwise, false.</returns>
        public bool Compare(object obj1, object obj2, ComparisonSettings settings)
        {
            if (obj1 == null)
            {
                obj1 = string.Empty;
            }

            if (obj2 == null)
            {
                obj2 = string.Empty;
            }

            return(obj1.Equals(obj2));
        }
Example #22
0
        public static IResultsOutputService SetupOutputService(ComparisonSettings settings)
        {
            var outputService = new ResultsOutputService(new TimeStampService());

            outputService.AddOutputter(new ResultsConsoleWriter());
            outputService.AddOutputter(new ResultsFileWriter(settings));

            if (settings.SendEmailWhenDone)
            {
                outputService.AddOutputter(new EmailSender(settings));
            }

            return(outputService);
        }
Example #23
0
        public override ObjectsComparer.IComparer <T> GetObjectsComparer <T>(ComparisonSettings settings = null, BaseComparer parentComparer = null)
        {
            var comparer = new ObjectsComparer.Comparer <T>(settings, parentComparer, this);

            //Do not compare Fields of Type Guid
            comparer.AddComparerOverride <Guid>(DoNotCompareValueComparer.Instance);

            //Do not compare fields of type dateTime
            comparer.AddComparerOverride <DateTime>(DoNotCompareValueComparer.Instance);

            //Do not compare field Id
            comparer.AddComparerOverride("Id", DoNotCompareValueComparer.Instance);

            return(comparer);
        }
Example #24
0
        public void RunFileCheck(ComparisonSettings settings, IResultsOutputService outputService)
        {
            _fileListService.PopulateFileList(settings);

            // this is not quite the right place for this...
            var filePairs = _fileListService.GetFilesInBothSides();

            PopulateFileHashValues(filePairs);

            var filesOnlyInLeft  = _fileListService.GetFilesOnlyInLeftSide();
            var filesOnlyInRight = _fileListService.GetFilesOnlyInRightSide();

            var results = new ComparisonResults(filePairs, filesOnlyInLeft, filesOnlyInRight);

            outputService.OutputResults(results, settings);
        }
Example #25
0
        /// <summary>
        /// Creates an instance of <see cref="Resemble"/> with default settings.
        /// Transparency - 1, DifferenceType - Flat, DifferenceColor - Color.Magenta.
        /// </summary>
        /// <param name="actualImage">Image to compare.</param>
        public Resemble(Image actualImage)
        {
            if (actualImage == null)
            {
                throw new ArgumentNullException(nameof(actualImage), "Actual image can not be null.");
            }

            _actualImage = new Bitmap(actualImage);
            _tolerance   = ToleranceSettings.Default;
            _settings    = new ComparisonSettings
            {
                Transparency    = 1,
                DifferenceType  = DifferenceType.Flat,
                DifferenceColor = Color.Magenta
            };
        }
Example #26
0
        //******************************************************
        //CompareTo
        //******************************************************
        /// <summary>
        ///    <para>Compares this object to another, based on specified options.</para>
        /// </summary>
        /// <param name='otherObject'>The object to which to compare this object. </param>
        /// <param name='settings'>Options on how to compare the objects. </param>
        /// <returns>
        /// <para><see langword='true'/> if the objects compared are equal
        ///    according to the given options; otherwise, <see langword='false'/>
        ///    .</para>
        /// </returns>
        public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
        {
            if (null == otherObject)
            {
                throw new ArgumentNullException("otherObject");
            }

            //
            // Removed Initialize call since wbemObject is a property that will call Initialize ( true ) on
            // its getter.
            //
            // Initialize ( ) ;
            bool result = false;

            if (null != wbemObject)
            {
                int status = (int)ManagementStatus.NoError;

                //
                // Removed Initialize call since wbemObject is a property that will call Initialize ( true ) on
                // its getter.
                //
                //otherObject.Initialize ( false ) ;

                status = wbemObject.CompareTo_((int)settings, otherObject.wbemObject);

                if ((int)ManagementStatus.Different == status)
                {
                    result = false;
                }
                else if ((int)ManagementStatus.NoError == status)
                {
                    result = true;
                }
                else if ((status & 0xfffff000) == 0x80041000)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                }
                else if (status < 0)
                {
                    Marshal.ThrowExceptionForHR(status);
                }
            }

            return(result);
        }
 public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
 {
     if (otherObject != null)
     {
         bool flag = false;
         if (this.wbemObject != null)
         {
             int num = this.wbemObject.CompareTo_((int)settings, otherObject.wbemObject);
             if (0x40003 != num)
             {
                 if (num != 0)
                 {
                     if (((long)num & (long)-4096) != (long)-2147217408)
                     {
                         if (num < 0)
                         {
                             Marshal.ThrowExceptionForHR(num);
                         }
                     }
                     else
                     {
                         ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
                     }
                 }
                 else
                 {
                     flag = true;
                 }
             }
             else
             {
                 flag = false;
             }
         }
         return(flag);
     }
     else
     {
         throw new ArgumentNullException("otherObject");
     }
 }
Example #28
0
        public override IComparer <T> GetObjectsComparer <T>(ComparisonSettings settings = null,
                                                             BaseComparer parentComparer = null)
        {
            if (typeof(T) == typeof(Person))
            {
                var comparer = new Comparer <Person>(settings, parentComparer, this);
                //Do not compare PersonId
                comparer.AddComparerOverride <Guid>(DoNotCompareValueComparer.Instance);
                //Sometimes MiddleName can be skipped. Compare only if property has value.
                comparer.AddComparerOverride(
                    () => new Person().MiddleName,
                    (s1, s2, parentSettings) => string.IsNullOrWhiteSpace(s1) || string.IsNullOrWhiteSpace(s2) || s1 == s2);
                comparer.AddComparerOverride(
                    () => new Person().PhoneNumber,
                    new PhoneNumberComparer());

                return((IComparer <T>)comparer);
            }

            return(base.GetObjectsComparer <T>(settings, parentComparer));
        }
Example #29
0
        /// <summary>
        /// Allows to pass all external settings at once./>
        /// </summary>
        /// <param name="newSettings">An instance of <see cref="ComparisonSettings"/> settings.</param>
        /// <returns>An instance of <see cref="Resemble"/>.</returns>
        public Resemble WithSettings(ComparisonSettings newSettings)
        {
            _settings = newSettings;

            if (newSettings.IgnoreAreasColoredWith.HasValue)
            {
                _settings.IgnoreAreasColoredWith = newSettings.IgnoreAreasColoredWith;
            }

            if (newSettings.DifferenceType.HasValue)
            {
                _settings.DifferenceType = newSettings.DifferenceType;
            }

            if (newSettings.Transparency.HasValue)
            {
                _settings.Transparency = newSettings.Transparency;
            }

            if (newSettings.DifferenceColor.HasValue)
            {
                _settings.DifferenceColor = newSettings.DifferenceColor;
            }

            if (newSettings.BoundingBoxes != null)
            {
                _settings.BoundingBoxes = newSettings.BoundingBoxes;
            }

            if (newSettings.IgnoredBoxes != null)
            {
                _settings.IgnoredBoxes = newSettings.IgnoredBoxes;
            }

            return(this);
        }
        //******************************************************
        //CompareTo
        //******************************************************
        /// <summary>
        ///    <para>Compares this object to another, based on specified options.</para>
        /// </summary>
        /// <param name='otherObject'>The object to which to compare this object. </param>
        /// <param name='settings'>Options on how to compare the objects. </param>
        /// <returns>
        /// <para><see langword='true'/> if the objects compared are equal 
        ///    according to the given options; otherwise, <see langword='false'/>
        ///    .</para>
        /// </returns>
        public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
        {
            if (null == otherObject)
                throw new ArgumentNullException ("otherObject");

            //
            // Removed Initialize call since wbemObject is a property that will call Initialize ( true ) on
            // its getter.
            //
            // Initialize ( ) ;
            bool result = false;

            if (null != wbemObject)
            {
                int status = (int) ManagementStatus.NoError;

                //
                // Removed Initialize call since wbemObject is a property that will call Initialize ( true ) on
                // its getter.
                //
                //otherObject.Initialize ( false ) ;

                status = wbemObject.CompareTo_((int) settings, otherObject.wbemObject);

                if ((int)ManagementStatus.Different == status)
                    result = false;
                else if ((int)ManagementStatus.NoError == status)
                    result = true;
                else if ((status & 0xfffff000) == 0x80041000)
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                else if (status < 0)
                    Marshal.ThrowExceptionForHR(status);
            }
            
            return result;
        }
Example #31
0
		public bool CompareTo (ManagementBaseObject otherObject, ComparisonSettings settings)
		{
			throw new NotImplementedException ();
		}
 public abstract bool Compare(object obj1, object obj2, ComparisonSettings settings);
 /// <summary>
 ///  Comparison widget settings class constructor
 /// </summary>
 public ComparisonWidgetSettings()
 {
     ComparisonBehavior = new ComparisonSettings();
     Locale = SupportedLocales.DefaultLocale;
 }
Example #34
0
		public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
		{
			if (otherObject != null)
			{
				bool flag = false;
				if (this.wbemObject != null)
				{
					int num = this.wbemObject.CompareTo_((int)settings, otherObject.wbemObject);
					if (0x40003 != num)
					{
						if (num != 0)
						{
							if (((long)num & (long)-4096) != (long)-2147217408)
							{
								if (num < 0)
								{
									Marshal.ThrowExceptionForHR(num);
								}
							}
							else
							{
								ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
							}
						}
						else
						{
							flag = true;
						}
					}
					else
					{
						flag = false;
					}
				}
				return flag;
			}
			else
			{
				throw new ArgumentNullException("otherObject");
			}
		}
	public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings) {}
 public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
 {
     if (otherObject == null)
     {
         throw new ArgumentNullException("otherObject");
     }
     bool flag = false;
     if (this.wbemObject != null)
     {
         int errorCode = 0;
         errorCode = this.wbemObject.CompareTo_((int) settings, otherObject.wbemObject);
         if (0x40003 == errorCode)
         {
             return false;
         }
         if (errorCode == 0)
         {
             return true;
         }
         if ((errorCode & 0xfffff000L) == 0x80041000L)
         {
             ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
             return flag;
         }
         if (errorCode < 0)
         {
             Marshal.ThrowExceptionForHR(errorCode);
         }
     }
     return flag;
 }