public void AllGetSetPropertyTest()
        {
            var type      = typeof(NormalPropertyClass);
            var members   = type.GetMembers();
            var property1 = members.Single(m => m.Name == nameof(NormalPropertyClass.PublicGetSet));
            var property2 = members.Single(m => m.Name == nameof(NormalPropertyClass.PublicGet));
            var property3 = members.Single(m => m.Name == nameof(NormalPropertyClass.PublicSet));

            var x1 = TypeVisit.GetProperties(type, PropertyAccessOptions.Both).ToList();
            var x2 = TypeVisit.GetProperties(type, PropertyAccessOptions.Getters).ToList();
            var x3 = TypeVisit.GetProperties(type, PropertyAccessOptions.Setters).ToList();

            x1.ShouldNotBeEmpty();
            x2.ShouldNotBeEmpty();
            x3.ShouldNotBeEmpty();

            x1.Count().ShouldBe(1);
            x2.Count().ShouldBe(2);
            x3.Count().ShouldBe(2);

            x1[0].ShouldBe(property1);

            x2[0].ShouldBe(property1);
            x2[1].ShouldBe(property2);

            x3[0].ShouldBe(property1);
            x3[1].ShouldBe(property3);
        }
Ejemplo n.º 2
0
 public static IEnumerable <PropertyInfo> GetProperties <T>(this T x, PropertyAccessOptions accessOptions, params Expression <Func <T, object> >[] propertySelectors)
 {
     if (x is null)
     {
         throw new ArgumentNullException(nameof(x));
     }
     return(TypeVisit.GetProperties(accessOptions, propertySelectors));
 }
Ejemplo n.º 3
0
 public static IEnumerable <PropertyInfo> GetProperties <T>(this T x, PropertyAccessOptions accessOptions = PropertyAccessOptions.Both)
 {
     return(TypeVisit.GetProperties(typeof(T), accessOptions));
 }