コード例 #1
0
ファイル: EzDb.cs プロジェクト: JacketsMask/SQLite-EZ-Mode
        private MetaSqliteRow CacheMetaRowExplicitTag(Type type)
        {
            MetaSqliteRow newCacheRow = new MetaSqliteRow();
            //Get table name
            SqliteTableAttribute tableAttribute = ((SqliteTableAttribute[])type.GetCustomAttributes(typeof(SqliteTableAttribute), inherit: false)).FirstOrDefault();

            if (tableAttribute == null)
            {
                throw new NotSupportedException("Expected Class attribute \"SqliteTable\"");
            }
            newCacheRow.TableName = tableAttribute.TableName;
            var propertyInfoList = type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            //Process properties
            foreach (PropertyInfo propertyInfo in propertyInfoList)
            {
                SqliteCellAttribute cellAttribute = ((SqliteCellAttribute[])propertyInfo.GetCustomAttributes(typeof(SqliteCellAttribute), inherit: false)).FirstOrDefault();
                if (cellAttribute == null)
                {
                    //Skip attributes that aren't tagged with EZ-Mode data types
                    continue;
                }
                newCacheRow.MetaSqliteCells.Add(new MetaSqliteCell(cellAttribute, propertyInfo, publicOnly: false));
            }
            //Add the row to the schema map for easier traversal in the future
            rowSchemaMap.Add(type, newCacheRow);
            return(newCacheRow);
        }
コード例 #2
0
        public MetaSqliteCell(SqliteCellAttribute cellAttribute, PropertyInfo propertyInfo, bool publicOnly)
        {
            this.OriginalType = propertyInfo.PropertyType;

            this.ColumnName  = cellAttribute.ColumnName != null ? cellAttribute.ColumnName : propertyInfo.Name;
            this.IsPrimaryId = cellAttribute.IsPrimaryId;

            this.CellAttribute = cellAttribute;

            this.GetValueMethod = propertyInfo.GetGetMethod(nonPublic: !publicOnly);
            this.SetValueMethod = propertyInfo.GetSetMethod(nonPublic: !publicOnly);
        }