public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            TemplateInstanceAttribute attribute = obj as TemplateInstanceAttribute;

            return((attribute != null) && (attribute.Instances == this.Instances));
        }
Exemple #2
0
		internal TemplateBuilder (ICustomAttributeProvider prov)
		{
			object[] ats = prov.GetCustomAttributes (typeof (TemplateContainerAttribute), true);
			if (ats.Length > 0)
				containerAttribute = (TemplateContainerAttribute) ats [0];

			ats = prov.GetCustomAttributes (typeof (TemplateInstanceAttribute), true);
			if (ats.Length > 0)
				instanceAttribute = (TemplateInstanceAttribute) ats [0];
		}
Exemple #3
0
        internal TemplateBuilder(ICustomAttributeProvider prov)
        {
            object[] ats = prov.GetCustomAttributes(typeof(TemplateContainerAttribute), true);
            if (ats.Length > 0)
            {
                containerAttribute = (TemplateContainerAttribute)ats [0];
            }

            ats = prov.GetCustomAttributes(typeof(TemplateInstanceAttribute), true);
            if (ats.Length > 0)
            {
                instanceAttribute = (TemplateInstanceAttribute)ats [0];
            }
        }
        /// <internalonly/>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            TemplateInstanceAttribute other = obj as TemplateInstanceAttribute;

            if (other != null)
            {
                return(other.Instances == Instances);
            }
            return(false);
        }
		static TemplateInstanceAttribute () {
			Single = new TemplateInstanceAttribute (TemplateInstance.Single);
			Multiple = new TemplateInstanceAttribute (TemplateInstance.Multiple);
			Default = Multiple;
		}
Exemple #6
0
        /// <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);
            }
        }
Exemple #7
0
 static TemplateInstanceAttribute()
 {
     Single   = new TemplateInstanceAttribute(TemplateInstance.Single);
     Multiple = new TemplateInstanceAttribute(TemplateInstance.Multiple);
     Default  = Multiple;
 }