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);
        }
Example #2
0
#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 override IEnumerable <ValidationResult> ValidateChildren()
        {
            var r = new List <ValidationResult>();
            var childrenResult = Property2.Validate();

            r.AddRange(childrenResult);
            return(r);
        }
Example #4
0
            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);
    }
Example #6
0
    public ClassWithExplicitInitializedAutoPropertiesAndExplicitBypassAutoPropertySettersWithVariableParameters()
    {
        var value = "Test" + Math.Abs(2);

        Property2.SetBackingField(value);

        var value2 = Property2 + "A";

        Property1.SetBackingField(value2);
    }
Example #7
0
        public SecondClass(BaseClass parent, int fieldInt, string fieldStr)
            : base(parent)
        {
            this.fieldInt = fieldInt;
            this.fieldStr = fieldStr;

            this.Data.Add("Property1", new MyData("Data_FieldOne", Property1));
            this.Data.Add("Property2", new MyData("Data_FieldTwo", Property2.ToString()));
            this.Data.Add("Property3", new MyData("Data_FieldThree", Property3));
        }
 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);
     }
 }
Example #9
0
            public override bool Equals(object obj)
            {
                var rhs = obj as MyKey;

                if (rhs == null)
                {
                    return(false);
                }

                return(Property1.Equals(rhs.Property1) &&
                       Property2.Equals(rhs.Property2));
            }
Example #10
0
        public void Receive_WithPromotedProps()
        {
            ReceivePipelineWrapper pipeline = Pipelines.Xml.Receive()
                                              .WithSpec <Schema2_WPP>();

            IBaseMessage input = MessageHelper.CreateFromStream(
                DocLoader.LoadStream("SampleDocument.xml")
                );
            MessageCollection output = pipeline.Execute(input);

            Property2 prop  = new Property2();
            object    value = output[0].Context.Read(prop.QName.Name, prop.QName.Namespace);

            Assert.AreEqual("Field2_0", value);
        }
    //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));
        }
    }
Example #12
0
 public void Method(Property2 p)
 {
     Console.WriteLine(p.GetType());
 }
 private int CustomGetHashCode()
 {
     return(Property2.GetHashCode());
 }
 public void Foo2()
 {
     Property2.Trim();
     Property1.Trim();
 }
Example #15
0
 public ClassWithExplicitInitializedAutoPropertiesAndExplicitBypassAutoPropertySetters()
 {
     Property1.SetBackingField("Test");
     Property2.SetBackingField("Test2");
 }
Example #16
0
 public override int GetHashCode()
 {
     return(Property1.GetHashCode() ^ Property2.GetHashCode());
 }
Example #17
0
 public Property1(Property2 p)
 {
 }