Пример #1
0
        public APGenElementMap(Type type)
        {
            _properties = new APGenPropertyCollection();

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

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

            foreach (PropertyInfo prop in props)
            {
                APGenPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APGenPropertyAttribute)) as APGenPropertyAttribute;
                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;

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

                property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute;
                _properties.Add(property);
            }
        }
Пример #2
0
		public APGenElementMap(Type type)
		{
			_properties = new APGenPropertyCollection();

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

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

			foreach (PropertyInfo prop in props)
			{
				APGenPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APGenPropertyAttribute)) as APGenPropertyAttribute;
				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;

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

				property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute;
				_properties.Add(property);
			}
		}
Пример #3
0
		static APGenAlias()
		{
			nameProp = new APGenProperty(
				"name",
				typeof(string),
				null,
				APCVHelper.WhiteSpaceTrimStringConverter,
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
		}
Пример #4
0
        static APGenAlias()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
        }
Пример #5
0
        internal APGenPropertyCollection GetKeyProperties()
        {
            if (_keyProps != null)
                return _keyProps;

            APGenPropertyCollection tmpkeyProps = new APGenPropertyCollection();

            foreach (APGenProperty prop in Properties)
            {
                if (prop.IsKey)
                    tmpkeyProps.Add(prop);
            }

            return _keyProps = tmpkeyProps;
        }
Пример #6
0
		static APGenIndex()
		{
			nameProp = new APGenProperty(
				"name",
				typeof(string),
				null,
				APCVHelper.WhiteSpaceTrimStringConverter,
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);
			isDefaultProp = new APGenProperty("isDefault", typeof(bool), false);
			ordersProp = new APGenProperty("", typeof(APGenOrderCollection), null, null, null, APGenPropertyOptions.IsDefaultCollection);


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
			properties.Add(isDefaultProp);
			properties.Add(ordersProp);
		}
Пример #7
0
        static APGenIndex()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );
            isDefaultProp = new APGenProperty("isDefault", typeof(bool), false);
            ordersProp    = new APGenProperty("", typeof(APGenOrderCollection), null, null, null, APGenPropertyOptions.IsDefaultCollection);


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
            properties.Add(isDefaultProp);
            properties.Add(ordersProp);
        }
Пример #8
0
        /// <summary>
        /// Writes the contents of this configuration element to the configuration file when implemented in a derived class.
        /// </summary>
        /// <param name="writer">The XmlWriter that writes to the configuration file.</param>
        /// <param name="serializeCollectionKey">true to serialize only the collection key properties; otherwise, false.</param>
        /// <returns>true if any data was actually serialized; otherwise, false.</returns>
        protected internal virtual bool SerializeElement(XmlWriter writer, bool serializeCollectionKey)
        {
            PreSerialize(writer);

            if (serializeCollectionKey)
            {
                APGenPropertyCollection props = GetKeyProperties();
                foreach (APGenProperty prop in props)
                    writer.WriteAttributeString(prop.Name, prop.ConvertToString(this[prop.Name]));
                return props.Count > 0;
            }

            bool wroteData = false;

            foreach (APGenPropertyInformation prop in ElementInformation.Properties)
            {
                if (prop.IsElement || prop.ValueOrigin == APGenPropertyValueOrigin.Default)
                    continue;

                if (!object.Equals(prop.Value, prop.DefaultValue))
                {
                    writer.WriteAttributeString(prop.Name, prop.GetStringValue());
                    wroteData = true;
                }
            }

            foreach (APGenPropertyInformation prop in ElementInformation.Properties)
            {
                if (!prop.IsElement)
                    continue;

                APGenElement val = prop.Value as APGenElement;
                if (val != null)
                    wroteData = val.SerializeToXmlElement(writer, prop.Name) || wroteData;
            }

            return wroteData;
        }
Пример #9
0
        static APGenTable()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );
            tableNameProp           = new APGenProperty("tableName", typeof(string));
            classNameProp           = new APGenProperty("className", typeof(string));
            dataInheritFromBaseProp = new APGenProperty("dataInheritFromBase", typeof(bool), true);
            dalInheritFromBaseProp  = new APGenProperty("dalInheritFromBase", typeof(bool), true);
            bplInheritFromBaseProp  = new APGenProperty("bplInheritFromBase", typeof(bool), true);
            inheritsProp            = new APGenProperty("inherits", typeof(string), "");
            commentProp             = new APGenProperty("comment", typeof(string));
            columnsProp             = new APGenProperty("columns", typeof(APGenColumnCollection));
            indexesProp             = new APGenProperty("indexes", typeof(APGenIndexCollection));
            uniquesProp             = new APGenProperty("uniques", typeof(APGenIndexCollection));
            aliasesProp             = new APGenProperty("aliases", typeof(APGenAliasCollection));


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
            properties.Add(tableNameProp);
            properties.Add(classNameProp);
            properties.Add(dataInheritFromBaseProp);
            properties.Add(dalInheritFromBaseProp);
            properties.Add(bplInheritFromBaseProp);
            properties.Add(inheritsProp);
            properties.Add(commentProp);
            properties.Add(columnsProp);
            properties.Add(indexesProp);
            properties.Add(uniquesProp);
            properties.Add(aliasesProp);
        }
Пример #10
0
		static APGenTable()
		{
			nameProp = new APGenProperty(
				"name",
				typeof(string),
				null, 
				APCVHelper.WhiteSpaceTrimStringConverter, 
				APCVHelper.NonEmptyStringValidator, 
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);
			tableNameProp = new APGenProperty("tableName", typeof(string));
			classNameProp = new APGenProperty("className", typeof(string));
			dataInheritFromBaseProp = new APGenProperty("dataInheritFromBase", typeof(bool), true);
			dalInheritFromBaseProp = new APGenProperty("dalInheritFromBase", typeof(bool), true);
			bplInheritFromBaseProp = new APGenProperty("bplInheritFromBase", typeof(bool), true);
			inheritsProp = new APGenProperty("inherits", typeof(string), "");
			commentProp = new APGenProperty("comment", typeof(string));
			columnsProp = new APGenProperty("columns", typeof(APGenColumnCollection));
			indexesProp = new APGenProperty("indexes", typeof(APGenIndexCollection));
			uniquesProp = new APGenProperty("uniques", typeof(APGenIndexCollection));
			aliasesProp = new APGenProperty("aliases", typeof(APGenAliasCollection));


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
			properties.Add(tableNameProp);
			properties.Add(classNameProp);
			properties.Add(dataInheritFromBaseProp);
			properties.Add(dalInheritFromBaseProp);
			properties.Add(bplInheritFromBaseProp);
			properties.Add(inheritsProp);
			properties.Add(commentProp);
			properties.Add(columnsProp);
			properties.Add(indexesProp);
			properties.Add(uniquesProp);
			properties.Add(aliasesProp);
		}
Пример #11
0
		static APGenOrder()
		{
			nameProp = new APGenProperty(
				"name",
				typeof(string),
				null,
				APCVHelper.WhiteSpaceTrimStringConverter,
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);
			accordingProp = new APGenProperty(
				"according",
				typeof(APSqlOrderAccording),
				APSqlOrderAccording.Asc,
				new GenericEnumAPConverter(typeof(APSqlOrderAccording)),
				APCVHelper.DefaultValidator,
				APGenPropertyOptions.None
				);


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
			properties.Add(accordingProp);
		}
Пример #12
0
        static APGenOrder()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );
            accordingProp = new APGenProperty(
                "according",
                typeof(APSqlOrderAccording),
                APSqlOrderAccording.Asc,
                new GenericEnumAPConverter(typeof(APSqlOrderAccording)),
                APCVHelper.DefaultValidator,
                APGenPropertyOptions.None
                );


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
            properties.Add(accordingProp);
        }
Пример #13
0
		static APGenColumn()
		{
			nameProp = new APGenProperty(
				"name", 
				typeof(string), 
				null, 
				APCVHelper.WhiteSpaceTrimStringConverter, 
				APCVHelper.NonEmptyStringValidator, 
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);
			columnNameProp = new APGenProperty("columnName", typeof(string));
			propertyNameProp = new APGenProperty("propertyName", typeof(string));
			typeProp = new APGenProperty(
				"type",
				typeof(string),
				"string",
				TypeDescriptor.GetConverter(typeof(string)),
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.None
				);
			isEnumProp = new APGenProperty("isEnum", typeof(bool), false);
			defaultValueProp = new APGenProperty("defaultValue", typeof(string), "");
			overrideProp = new APGenProperty("override", typeof(bool), false);
			identityTypeProp = new APGenProperty(
				"identityType",
				typeof(APColumnIdentityType),
				APColumnIdentityType.None,
				new GenericEnumAPConverter(typeof(APColumnIdentityType)),
				APCVHelper.DefaultValidator, 
				APGenPropertyOptions.None
				);
			providerIdentityBaseProp = new APGenProperty("providerIdentityBase", typeof(int), 5000);
			isNullableProp = new APGenProperty("isNullable", typeof(bool), false);
			primaryKeyProp = new APGenProperty("primaryKey", typeof(bool), false);
			dbTypeProp = new APGenProperty(
				"dbType",
				typeof(DbType),
				DbType.Object,
				new GenericEnumAPConverter(typeof(DbType)),
				APCVHelper.DefaultValidator, 
				APGenPropertyOptions.None
				);
			dbDefaultValueProp = new APGenProperty("dbDefaultValue", typeof(string));
			dataLengthProp = new APGenProperty("dataLength", typeof(int), 0);
			precisionProp = new APGenProperty("precision", typeof(int), 18);
			scaleProp = new APGenProperty("scale", typeof(int), 0);
			commentProp = new APGenProperty("comment", typeof(string));
			displayProp = new APGenProperty("display", typeof(string));
			requiredProp = new APGenProperty("required", typeof(bool));


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
			properties.Add(columnNameProp);
			properties.Add(propertyNameProp);
			properties.Add(typeProp);
			properties.Add(isEnumProp);
			properties.Add(defaultValueProp);
			properties.Add(overrideProp);
			properties.Add(identityTypeProp);
			properties.Add(providerIdentityBaseProp);
			properties.Add(isNullableProp);
			properties.Add(primaryKeyProp);
			properties.Add(dbTypeProp);
			properties.Add(dbDefaultValueProp);
			properties.Add(dataLengthProp);
			properties.Add(precisionProp);
			properties.Add(scaleProp);
			properties.Add(commentProp);
			properties.Add(displayProp);
			properties.Add(requiredProp);
		}
		static NameValueAPGenElementCollection()
		{
			properties = new APGenPropertyCollection();
		}
Пример #15
0
 static APGenDefaultSection()
 {
     properties = new APGenPropertyCollection();
 }
Пример #16
0
		static APGenDefaultSection()
		{
			properties = new APGenPropertyCollection();
		}
Пример #17
0
 static NameValueAPGenElementCollection()
 {
     properties = new APGenPropertyCollection();
 }
Пример #18
0
        static APGenColumn()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );
            columnNameProp   = new APGenProperty("columnName", typeof(string));
            propertyNameProp = new APGenProperty("propertyName", typeof(string));
            typeProp         = new APGenProperty(
                "type",
                typeof(string),
                "string",
                TypeDescriptor.GetConverter(typeof(string)),
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.None
                );
            isEnumProp       = new APGenProperty("isEnum", typeof(bool), false);
            defaultValueProp = new APGenProperty("defaultValue", typeof(string), "");
            overrideProp     = new APGenProperty("override", typeof(bool), false);
            identityTypeProp = new APGenProperty(
                "identityType",
                typeof(APColumnIdentityType),
                APColumnIdentityType.None,
                new GenericEnumAPConverter(typeof(APColumnIdentityType)),
                APCVHelper.DefaultValidator,
                APGenPropertyOptions.None
                );
            providerIdentityBaseProp = new APGenProperty("providerIdentityBase", typeof(int), 5000);
            isNullableProp           = new APGenProperty("isNullable", typeof(bool), false);
            primaryKeyProp           = new APGenProperty("primaryKey", typeof(bool), false);
            dbTypeProp = new APGenProperty(
                "dbType",
                typeof(DbType),
                DbType.Object,
                new GenericEnumAPConverter(typeof(DbType)),
                APCVHelper.DefaultValidator,
                APGenPropertyOptions.None
                );
            dbDefaultValueProp = new APGenProperty("dbDefaultValue", typeof(string));
            dataLengthProp     = new APGenProperty("dataLength", typeof(int), 0);
            precisionProp      = new APGenProperty("precision", typeof(int), 18);
            scaleProp          = new APGenProperty("scale", typeof(int), 0);
            commentProp        = new APGenProperty("comment", typeof(string));
            displayProp        = new APGenProperty("display", typeof(string));
            requiredProp       = new APGenProperty("required", typeof(bool));


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
            properties.Add(columnNameProp);
            properties.Add(propertyNameProp);
            properties.Add(typeProp);
            properties.Add(isEnumProp);
            properties.Add(defaultValueProp);
            properties.Add(overrideProp);
            properties.Add(identityTypeProp);
            properties.Add(providerIdentityBaseProp);
            properties.Add(isNullableProp);
            properties.Add(primaryKeyProp);
            properties.Add(dbTypeProp);
            properties.Add(dbDefaultValueProp);
            properties.Add(dataLengthProp);
            properties.Add(precisionProp);
            properties.Add(scaleProp);
            properties.Add(commentProp);
            properties.Add(displayProp);
            properties.Add(requiredProp);
        }
Пример #19
0
		static APGenRelation()
		{
			nameProp = new APGenProperty(
				"name",
				typeof(string),
				null,
				APCVHelper.WhiteSpaceTrimStringConverter,
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
				);
			masterTableProp = new APGenProperty(
				"masterTable",
				typeof(string),
				"",
				TypeDescriptor.GetConverter(typeof(string)),
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired
				);
			masterColumnProp = new APGenProperty(
				"masterColumn",
				typeof(string),
				"",
				TypeDescriptor.GetConverter(typeof(string)),
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired
				);
			slaveTableProp = new APGenProperty(
				"slaveTable",
				typeof(string),
				"",
				TypeDescriptor.GetConverter(typeof(string)),
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired
				);
			slaveColumnProp = new APGenProperty(
				"slaveColumn",
				typeof(string),
				"",
				TypeDescriptor.GetConverter(typeof(string)),
				APCVHelper.NonEmptyStringValidator,
				APGenPropertyOptions.IsRequired
				);
			cascadeTypeProp = new APGenProperty(
				"cascadeType",
				typeof(APRelationCascadeType),
				APRelationCascadeType.None,
				new GenericEnumAPConverter(typeof(APRelationCascadeType)),
				APCVHelper.DefaultValidator,
				APGenPropertyOptions.None
				);
			commentProp = new APGenProperty("comment", typeof(string));


			properties = new APGenPropertyCollection();
			properties.Add(nameProp);
			properties.Add(masterTableProp);
			properties.Add(masterColumnProp);
			properties.Add(slaveTableProp);
			properties.Add(slaveColumnProp);
			properties.Add(cascadeTypeProp);
			properties.Add(commentProp);
		}
Пример #20
0
		internal APGenPropertyCollection GetKeyProperties()
		{
			if (_keyProps != null)
				return _keyProps;

			APGenPropertyCollection tmpkeyProps = new APGenPropertyCollection();

			foreach (APGenProperty prop in Properties)
			{
				if (prop.IsKey)
					tmpkeyProps.Add(prop);
			}

			return _keyProps = tmpkeyProps;
		}
Пример #21
0
        static APGenRelation()
        {
            nameProp = new APGenProperty(
                "name",
                typeof(string),
                null,
                APCVHelper.WhiteSpaceTrimStringConverter,
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey
                );
            masterTableProp = new APGenProperty(
                "masterTable",
                typeof(string),
                "",
                TypeDescriptor.GetConverter(typeof(string)),
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired
                );
            masterColumnProp = new APGenProperty(
                "masterColumn",
                typeof(string),
                "",
                TypeDescriptor.GetConverter(typeof(string)),
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired
                );
            slaveTableProp = new APGenProperty(
                "slaveTable",
                typeof(string),
                "",
                TypeDescriptor.GetConverter(typeof(string)),
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired
                );
            slaveColumnProp = new APGenProperty(
                "slaveColumn",
                typeof(string),
                "",
                TypeDescriptor.GetConverter(typeof(string)),
                APCVHelper.NonEmptyStringValidator,
                APGenPropertyOptions.IsRequired
                );
            cascadeTypeProp = new APGenProperty(
                "cascadeType",
                typeof(APRelationCascadeType),
                APRelationCascadeType.None,
                new GenericEnumAPConverter(typeof(APRelationCascadeType)),
                APCVHelper.DefaultValidator,
                APGenPropertyOptions.None
                );
            commentProp = new APGenProperty("comment", typeof(string));


            properties = new APGenPropertyCollection();
            properties.Add(nameProp);
            properties.Add(masterTableProp);
            properties.Add(masterColumnProp);
            properties.Add(slaveTableProp);
            properties.Add(slaveColumnProp);
            properties.Add(cascadeTypeProp);
            properties.Add(commentProp);
        }