Esempio n. 1
0
		public APXmlElementMap(Type type)
		{
			_properties = new APXmlPropertyCollection();

			_collectionAttribute = Attribute.GetCustomAttribute(type, typeof(APXmlCollectionAttribute)) as APXmlCollectionAttribute;

			PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

			foreach (PropertyInfo prop in props)
			{
				APXmlPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APXmlPropertyAttribute)) as APXmlPropertyAttribute;
				if (attr == null)
					continue;
				string name = attr.Name != null ? attr.Name : prop.Name;

				APValidatorAttribute validatorAttr = Attribute.GetCustomAttribute(prop, typeof(APValidatorAttribute)) as APValidatorAttribute;
				APValidatorBase validator = validatorAttr != null ? validatorAttr.ValidatorInstance : null;

				TypeConverterAttribute convertAttr = Attribute.GetCustomAttribute(prop, typeof(TypeConverterAttribute)) as TypeConverterAttribute;
				TypeConverter converter = convertAttr != null ? (TypeConverter)Activator.CreateInstance(Type.GetType(convertAttr.ConverterTypeName), true) : null;

				APXmlProperty property = new APXmlProperty(name, prop.PropertyType, attr.DefaultValue, converter, validator, attr.Options);

				property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APXmlCollectionAttribute)) as APXmlCollectionAttribute;
				_properties.Add(property);
			}
		}
Esempio n. 2
0
		static APRptReferDef()
		{
			columnIdProp = new APXmlProperty("columnId", typeof(string), "", APXmlPropertyOptions.IsRequired | APXmlPropertyOptions.IsKey);

			properties = new APXmlPropertyCollection();
			properties.Add(columnIdProp);
		}
Esempio n. 3
0
        public APXmlElementMap(Type type)
        {
            _properties = new APXmlPropertyCollection();

            _collectionAttribute = Attribute.GetCustomAttribute(type, typeof(APXmlCollectionAttribute)) as APXmlCollectionAttribute;

            PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

            foreach (PropertyInfo prop in props)
            {
                APXmlPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APXmlPropertyAttribute)) as APXmlPropertyAttribute;
                if (attr == null)
                {
                    continue;
                }
                string name = attr.Name != null ? attr.Name : prop.Name;

                APValidatorAttribute validatorAttr = Attribute.GetCustomAttribute(prop, typeof(APValidatorAttribute)) as APValidatorAttribute;
                APValidatorBase      validator     = validatorAttr != null ? validatorAttr.ValidatorInstance : null;

                TypeConverterAttribute convertAttr = Attribute.GetCustomAttribute(prop, typeof(TypeConverterAttribute)) as TypeConverterAttribute;
                TypeConverter          converter   = convertAttr != null ? (TypeConverter)Activator.CreateInstance(Type.GetType(convertAttr.ConverterTypeName), true) : null;

                APXmlProperty property = new APXmlProperty(name, prop.PropertyType, attr.DefaultValue, converter, validator, attr.Options);

                property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APXmlCollectionAttribute)) as APXmlCollectionAttribute;
                _properties.Add(property);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Specifies whether the APXmlProperty is contained in this collection.
        /// </summary>
        /// <param name="name">An identifier for the APXmlProperty to verify.</param>
        /// <returns>true if the specified APXmlProperty is contained in the collection; otherwise, false.</returns>
        public bool Contains(string name)
        {
            APXmlProperty property = this[name];

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

            return(_collection.Contains(property));
        }
Esempio n. 5
0
 /// <summary>
 /// Sets a property to the specified value.
 /// </summary>
 /// <param name="prop">The element property to set.</param>
 /// <param name="value">The value to assign to the property.</param>
 protected void SetPropertyValue(APXmlProperty prop, object value)
 {
     try
     {
         prop.Validate(value);
     }
     catch (Exception e)
     {
         throw new APXmlException(APResource.GetString(APResource.APXml_PropertyValueInvalid, prop.Name, e.Message), e);
     }
 }
Esempio n. 6
0
		static APRptConditionDef()
		{
			logicProp = new APXmlProperty("logic", typeof(string), "");
			rpnProp = new APXmlProperty("rpn", typeof(string), "");
			filtersProp = new APXmlProperty("", typeof(APRptFilterDefCollection), null, APXmlPropertyOptions.IsDefaultCollection);

			properties = new APXmlPropertyCollection();
			properties.Add(logicProp);
			properties.Add(rpnProp);
			properties.Add(filtersProp);
		}
Esempio n. 7
0
		static APRptOrderDef()
		{
			columnIdProp = new APXmlProperty("columnId", typeof(string), "", APXmlPropertyOptions.IsRequired | APXmlPropertyOptions.IsKey);
			accordingProp = new APXmlProperty("according", typeof(APSqlOrderAccording), APSqlOrderAccording.Asc,
				new GenericEnumAPConverter(typeof(APSqlOrderAccording)),
				APCVHelper.DefaultValidator,
				APXmlPropertyOptions.IsRequired);

			properties = new APXmlPropertyCollection();
			properties.Add(columnIdProp);
			properties.Add(accordingProp);
		}
Esempio n. 8
0
		static APRptViewDef()
		{
			nameProp = new APXmlProperty("name", typeof(string), "");
			refersProp = new APXmlProperty("refers", typeof(APRptReferDefCollection));
			ordersProp = new APXmlProperty("orders", typeof(APRptOrderDefCollection));
			conditionProp = new APXmlProperty("condition", typeof(APRptConditionDef));

			properties = new APXmlPropertyCollection();
			properties.Add(nameProp);
			properties.Add(refersProp);
			properties.Add(ordersProp);
			properties.Add(conditionProp);
		}
Esempio n. 9
0
        private void ValidateValue(APXmlProperty property, string value)
        {
            APValidatorBase validator;

            if (property == null || (validator = property.Validator) == null)
            {
                return;
            }

            if (!validator.CanValidate(property.Type))
            {
                throw new APXmlException(APResource.GetString(APResource.APXml_ValidatorNotSupportType, property.Type));
            }
            validator.Validate(property.ConvertFromString(value));
        }
Esempio n. 10
0
		static APRptFilterDef()
		{
			serialProp = new APXmlProperty("serial", typeof(string), "", APXmlPropertyOptions.IsRequired | APXmlPropertyOptions.IsKey);
			columnIdProp = new APXmlProperty("columnId", typeof(string), "", APXmlPropertyOptions.IsRequired);
			comparatorProp = new APXmlProperty("comparator", typeof(APRptFilterComparator), APRptFilterComparator.Equals,
				new GenericEnumAPConverter(typeof(APRptFilterComparator)),
				APCVHelper.DefaultValidator,
				APXmlPropertyOptions.IsRequired);
			valuesProp = new APXmlProperty("values", typeof(string), "");

			properties = new APXmlPropertyCollection();
			properties.Add(serialProp);
			properties.Add(columnIdProp);
			properties.Add(comparatorProp);
			properties.Add(valuesProp);
		}
Esempio n. 11
0
		static APRptReportDef()
		{
			nameProp = new APXmlProperty("name", typeof(string), "");
			refersProp = new APXmlProperty("refers", typeof(APRptReferDefCollection));
			ordersProp = new APXmlProperty("orders", typeof(APRptOrderDefCollection));
			groupsProp = new APXmlProperty("groups", typeof(APRptGroupDefCollection));
			conditionProp = new APXmlProperty("condition", typeof(APRptConditionDef));
			showSummaryProp = new APXmlProperty("showSummary", typeof(bool), true);
			frameColumnIdProp = new APXmlProperty("frameColumnId", typeof(string), "");
			frameBeginProp = new APXmlProperty("frameBegin", typeof(string), "");
			frameEndProp = new APXmlProperty("frameEnd", typeof(string), "");

			properties = new APXmlPropertyCollection();
			properties.Add(nameProp);
			properties.Add(refersProp);
			properties.Add(ordersProp);
			properties.Add(groupsProp);
			properties.Add(showSummaryProp);
			properties.Add(frameColumnIdProp);
			properties.Add(frameBeginProp);
			properties.Add(frameEndProp);
			properties.Add(conditionProp);
		}
Esempio n. 12
0
        internal APXmlElementCollection GetDefaultCollection()
        {
            if (_defaultCollection != null)
            {
                return(_defaultCollection);
            }

            APXmlProperty defaultCollectionProp = null;

            foreach (APXmlProperty prop in Properties)
            {
                if (prop.IsDefaultCollection)
                {
                    defaultCollectionProp = prop;
                    break;
                }
            }

            if (defaultCollectionProp != null)
            {
                _defaultCollection = this[defaultCollectionProp] as APXmlElementCollection;
            }
            return(_defaultCollection);
        }
		/// <summary>
		/// Adds a APXmlProperty to the collection.
		/// </summary>
		/// <param name="property">The APXmlProperty to add.</param>
		public void Add(APXmlProperty property)
		{
			_collection.Add(property);
		}
Esempio n. 14
0
		private void ValidateValue(APXmlProperty property, string value)
		{
			APValidatorBase validator;

			if (property == null || (validator = property.Validator) == null)
				return;

			if (!validator.CanValidate(property.Type))
				throw new APXmlException(APResource.GetString(APResource.APXml_ValidatorNotSupportType, property.Type));
			validator.Validate(property.ConvertFromString(value));
		}
Esempio n. 15
0
		/// <summary>
		/// Gets or sets a property or attribute of this element.
		/// </summary>
		/// <param name="property">The property to access.</param>
		/// <returns>The specified property, attribute, or child element.</returns>
		protected internal object this[APXmlProperty property]
		{
			get { return this[property.Name]; }
			set { this[property.Name] = value; }
		}
Esempio n. 16
0
		/// <summary>
		/// Sets a property to the specified value.
		/// </summary>
		/// <param name="prop">The element property to set.</param>
		/// <param name="value">The value to assign to the property.</param>
		protected void SetPropertyValue(APXmlProperty prop, object value)
		{
			try
			{
				prop.Validate(value);
			}
			catch (Exception e)
			{
				throw new APXmlException(APResource.GetString(APResource.APXml_PropertyValueInvalid, prop.Name, e.Message), e);
			}
		}
Esempio n. 17
0
 /// <summary>
 /// Gets or sets a property or attribute of this element.
 /// </summary>
 /// <param name="property">The property to access.</param>
 /// <returns>The specified property, attribute, or child element.</returns>
 protected internal object this[APXmlProperty property]
 {
     get { return(this[property.Name]); }
     set { this[property.Name] = value; }
 }
		internal APXmlPropertyInformation(APXmlElement owner, APXmlProperty property)
		{
			_owner = owner;
			_property = property;
		}
Esempio n. 19
0
 internal APXmlPropertyInformation(APXmlElement owner, APXmlProperty property)
 {
     _owner    = owner;
     _property = property;
 }
		/// <summary>
		/// Copies this APXmlPropertyCollection to an array.
		/// </summary>
		/// <param name="array">Array to which to copy.</param>
		/// <param name="index">Index at which to begin copying.</param>
		public void CopyTo(APXmlProperty[] array, int index)
		{
			_collection.CopyTo(array, index);
		}
Esempio n. 21
0
 /// <summary>
 /// Adds a APXmlProperty to the collection.
 /// </summary>
 /// <param name="property">The APXmlProperty to add.</param>
 public void Add(APXmlProperty property)
 {
     _collection.Add(property);
 }