#pragma warning restore 649 public ClassWithExplicitInitializedAutoPropertiesAndExplicitBypassAutoPropertySettersWithComplexParameter() { Property2.SetBackingField("Test" + Math.Abs(2)); Property1.SetBackingField(Property2 + "A"); Property1.SetBackingField(Property2.TrimEnd('2')); Property3.SetBackingField(Property1 == "Test2A" || !_x); }
public void BuildSetter_StandardType_BuildsSetters() { var flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; var now = DateTime.Now; var propertySetter1 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property1", flags)); propertySetter1(this, (long?)1); var propertySetter2 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property2", flags)); propertySetter2(this, (long)2); var propertySetter3 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property3", flags)); propertySetter3(this, now); var propertySetter4 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property4", flags)); propertySetter4(this, now); var propertySetter5 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property5", flags)); propertySetter5(this, "str"); var propertySetter6 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property6", flags)); propertySetter6(this, SomeEnum.Value1); var propertySetter7 = DelegateBuilder.BuildSetter <DelegateBuilderTest>(GetType().GetProperty("Property7", flags)); propertySetter7(this, SomeEnum.Value2); Property1.Should().Be.EqualTo(1); Property2.Should().Be.EqualTo(2); Property3.Should().Be.EqualTo(now); Property4.Should().Be.EqualTo(now); Property5.Should().Be.EqualTo("str"); Property6.Should().Be.EqualTo(SomeEnum.Value1); Property7.Should().Be.EqualTo(SomeEnum.Value2); }
public override int GetHashCode() { int hash = 13; hash = (hash * 7) + Property1.GetHashCode(); hash = (hash * 7) + Property2.GetHashCode(); hash = (hash * 7) + Property3.GetHashCode(); return(hash); }
public int HashHelpers() { var hash = Property1.GetHashCode(); hash = Combine(hash, Property2?.GetHashCode(StringComparison.Ordinal) ?? 0); hash = Combine(hash, Property3.GetHashCode()); hash = Combine(hash, Property4); return(hash); }
public int ReSharper() { unchecked { var hash = Property1.GetHashCode(); hash = (hash * 397) ^ (Property2?.GetHashCode(StringComparison.Ordinal) ?? 0); hash = (hash * 397) ^ Property3.GetHashCode(); hash = (hash * 397) ^ Property4; return(hash); } }
//Include properties, constructor, and INotifyPropertyChanged interface members. public override bool Equals(object obj) { CustomObject test = obj as CustomObject; //test=null if obj cannot be casted. if (test == null) { return(false); //Comparing null against non-null: FALSE } else { //Check if all properties are equal. return((Property1.CompareTo(test.Property1) == 0) && (Property2.CompareTo(test.Property2) == 0) && (Property3.CompareTo(test.Property3) == 0)); } }