public void Deny_Unrestricted () { PersistenceModeAttribute pma = new PersistenceModeAttribute (PersistenceMode.Attribute); Assert.AreEqual (PersistenceMode.Attribute, pma.Mode, "Mode"); Assert.IsTrue (pma.Equals (pma), "Equals"); Assert.IsTrue (pma.IsDefaultAttribute (), "IsDefaultAttribute"); }
public override bool Equals(object obj) { PersistenceModeAttribute pma = (obj as PersistenceModeAttribute); if (pma == null) { return(false); } return(pma.mode == mode); }
/// <summary> /// Construct an instance of a ReflectedControlProperty, given the control for this property and the /// pre-reflected PropertyInfo for the property in question. /// </summary> /// <param name="reflectedControl">The control that owns this property.</param> /// <param name="propertyInfo">The pre-reflected PropertyInfo for this property.</param> public ReflectedControlProperty(ReflectedControl reflectedControl, PropertyInfo propertyInfo) { ReflectedControl = reflectedControl; PropertyInfo = propertyInfo; var custAtts = CustomAttributeData.GetCustomAttributes(PropertyInfo).Where(a => a.AttributeType == typeof(System.Web.UI.PersistenceModeAttribute)); if (custAtts.Any()) { var parseAtt = custAtts.First(); // public PersistenceModeAttribute(PersistenceMode mode); if (parseAtt.ConstructorArguments.Count == 1) { PersistenceMode val = (PersistenceMode)parseAtt.ConstructorArguments[0].Value; PersistenceModeAttribute = new System.Web.UI.PersistenceModeAttribute(val); //public ParseChildrenAttribute(); } } else { PersistenceModeAttribute = null; } //System.Web.UI.PersistenceModeAttribute[] persistenceModeAttributes = (System.Web.UI.PersistenceModeAttribute[])propertyInfo.GetCustomAttributes(typeof(System.Web.UI.PersistenceModeAttribute), true); //PersistenceModeAttribute = persistenceModeAttributes.Length == 0 ? null : persistenceModeAttributes[0]; IsTemplateProperty = typeof(System.Web.UI.ITemplate).IsAssignableFrom(PropertyInfo.PropertyType); IsCollectionProperty = typeof(IEnumerable).IsAssignableFrom(PropertyInfo.PropertyType) && !IsTemplateProperty; if (IsTemplateProperty) { var custTemplateInstanceAtts = CustomAttributeData.GetCustomAttributes(PropertyInfo).Where(a => a.AttributeType == typeof(System.Web.UI.TemplateInstanceAttribute)); if (custTemplateInstanceAtts.Any()) { var parseAtt = custTemplateInstanceAtts.First(); // public TemplateInstanceAttribute(TemplateInstance instances); if (parseAtt.ConstructorArguments.Count == 1) { TemplateInstance val = (TemplateInstance)parseAtt.ConstructorArguments[0].Value; TemplateInstanceAttribute = new System.Web.UI.TemplateInstanceAttribute(val); //public ParseChildrenAttribute(); } } else { TemplateInstanceAttribute = null; } //System.Web.UI.TemplateInstanceAttribute[] templateInstanceAttributes = (System.Web.UI.TemplateInstanceAttribute[])propertyInfo.GetCustomAttributes(typeof(System.Web.UI.TemplateInstanceAttribute), true); //TemplateInstanceAttribute = templateInstanceAttributes.Length == 0 ? null : templateInstanceAttributes[0]; var custTemplateContainerAtts = CustomAttributeData.GetCustomAttributes(PropertyInfo).Where(a => a.AttributeType == typeof(System.Web.UI.TemplateContainerAttribute)); if (custTemplateContainerAtts.Any()) { var parseAtt = custTemplateContainerAtts.First(); if (parseAtt.ConstructorArguments.Count == 1) { // public TemplateContainerAttribute(Type containerType); Type val = (Type)parseAtt.ConstructorArguments[0].Value; TemplateContainerAttribute = new System.Web.UI.TemplateContainerAttribute(val); } else if (parseAtt.ConstructorArguments.Count == 2) { // public TemplateContainerAttribute(Type containerType, BindingDirection bindingDirection); Type val = (Type)parseAtt.ConstructorArguments[0].Value; BindingDirection dir = (BindingDirection)parseAtt.ConstructorArguments[1].Value; TemplateContainerAttribute = new System.Web.UI.TemplateContainerAttribute(val, dir); } } else { TemplateContainerAttribute = null; } //System.Web.UI.TemplateContainerAttribute[] templateContainerAttributes = (System.Web.UI.TemplateContainerAttribute[])propertyInfo.GetCustomAttributes(typeof(System.Web.UI.TemplateContainerAttribute), true); //TemplateContainerAttribute = templateContainerAttributes.Length == 0 ? null : templateContainerAttributes[0]; } else if (IsCollectionProperty) { CollectionItemTypes = GetCollectionItemTypes(PropertyInfo.PropertyType); } }