public void Ctor_Bool(bool recommendAsConfigurable)
        {
            var attribute = new RecommendedAsConfigurableAttribute(recommendAsConfigurable);

            Assert.Equal(recommendAsConfigurable, attribute.RecommendedAsConfigurable);
            Assert.Equal(!recommendAsConfigurable, attribute.IsDefaultAttribute());
        }
 public void Equals_Object_ReturnsExpected(RecommendedAsConfigurableAttribute attribute, object other, bool expected)
 {
     Assert.Equal(expected, attribute.Equals(other));
     if (other is RecommendedAsConfigurableAttribute)
     {
         Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode()));
     }
 }
        public void No_Get_ReturnsExpected()
        {
            RecommendedAsConfigurableAttribute attribute = RecommendedAsConfigurableAttribute.No;

            Assert.Same(attribute, RecommendedAsConfigurableAttribute.No);
            Assert.False(attribute.RecommendedAsConfigurable);
            Assert.True(attribute.IsDefaultAttribute());
        }
Esempio n. 4
0
        // Determine if two attribute values are equal.
        public override bool Equals(Object obj)
        {
            RecommendedAsConfigurableAttribute other =
                (obj as RecommendedAsConfigurableAttribute);

            if (other != null)
            {
                return(flag == other.flag);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
    public void Method()
    {
// <Snippet1>
        // Gets the attributes for the property.
        AttributeCollection attributes =
            TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

        // Checks to see if the property is recommended as configurable.
        RecommendedAsConfigurableAttribute myAttribute =
            (RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];

        if (myAttribute.RecommendedAsConfigurable)
        {
            // Insert code here.
        }

// </Snippet1>
    }
        public static IEnumerable <object[]> Equals_TestData()
        {
            var attribute = new RecommendedAsConfigurableAttribute(true);

            yield return(new object[] { attribute, attribute, true });

            yield return(new object[] { attribute, new RecommendedAsConfigurableAttribute(true), true });

            yield return(new object[] { attribute, new RecommendedAsConfigurableAttribute(false), false });

            yield return(new object[] { new RecommendedAsConfigurableAttribute(false), new RecommendedAsConfigurableAttribute(false), true });

            yield return(new object[] { new RecommendedAsConfigurableAttribute(false), new RecommendedAsConfigurableAttribute(true), false });

            yield return(new object[] { attribute, new object(), false });

            yield return(new object[] { attribute, null, false });
        }
Esempio n. 7
0
    // </Snippet1>
    public void Method1()
    {
        // <Snippet2>
        // Gets the attributes for the property.
        AttributeCollection attributes =
            TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

        // Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
        if (attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes))
        {
            // Insert code here.
        }

        // This is another way to see if the property is recommended as configurable.
        RecommendedAsConfigurableAttribute myAttribute =
            (RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];

        if (myAttribute.RecommendedAsConfigurable)
        {
            // Insert code here.
        }
        // </Snippet2>
    }