private static IArray <ColumnMetadata> ParseColumns( Type itemType, IArray <ColumnStaticMetadata> staticMetadata, IEnumerable <string> allowedPrivate) { // Properties. // Public. IEnumerable <PropertyInfo> properties = itemType.GetProperties(BindingFlags.Instance | BindingFlags.Public); // Private. if (allowedPrivate != null) { var allowed = new HashSet <string>(allowedPrivate, StringComparer.OrdinalIgnoreCase); var privateProperties = itemType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic); properties = properties.Concat(privateProperties.Where(p => allowed.Contains(p.Name))); } // Build. var cols = new List <ColumnMetadata>(); foreach (PropertyInfo property in properties) { var fieldName = GetFieldName(property.Name); var staticMeta = staticMetadata .FirstOrDefault(c => c.Name.Equals(fieldName, StringComparison.OrdinalIgnoreCase)); // Type. if (property.PropertyType == typeof(byte)) { cols.Add(new ColumnMetadata(EFieldType.Byte, fieldName)); } else if (property.PropertyType == typeof(bool)) { cols.Add(new ColumnMetadata(EFieldType.Bool, fieldName)); } else if (property.PropertyType == typeof(short)) { cols.Add(new ColumnMetadata(EFieldType.Int16, fieldName)); } else if (property.PropertyType == typeof(int)) { cols.Add(new ColumnMetadata(EFieldType.Int32, fieldName)); } else if (property.PropertyType == typeof(long)) { cols.Add(new ColumnMetadata(EFieldType.Int64, fieldName)); } else if (property.PropertyType == typeof(double)) { cols.Add(new ColumnMetadata(EFieldType.Double, fieldName)); } else if (property.PropertyType == typeof(string)) { var maxLen = staticMeta != null ? staticMeta.MaxLength : (int?)null; cols.Add(new ColumnMetadata(EFieldType.String, fieldName, maxLen)); } else { throw new NJournalConfigurationException("Unsupported property type " + property.PropertyType); } } var issetField = itemType.GetField(MetadataConstants.ISSET_FIELD_NAME); if (issetField.FieldType.Name.EndsWith("Isset")) { cols.Add(new ColumnMetadata(EFieldType.BitSet, ISSET_COLUMN_NAME)); } return(new ArrayWrapper <ColumnMetadata>(cols)); }