コード例 #1
0
        /// <summary>
        /// Creates a TypeMap for a given Type.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>TypeMap</returns>
        private EntityTypeMap CreateTypeMap(Type type)
        {
            //var conventionIdentifiers = Configuration.IdentifierConventions.Select( applyIdentifierConvention => applyIdentifierConvention( type ) ).ToList();

            var fieldsAndProperties = CreateFieldAndPropertyInfoDictionary(type);

            var identifiers = new List <string>();

            foreach (var fieldOrProperty in fieldsAndProperties)
            {
                var memberName = fieldOrProperty.Key;

                var member = fieldOrProperty.Value;

                var fieldInfo = member as FieldInfo;

                if (fieldInfo != null)
                {
                    //if ( fieldInfo.GetCustomAttributes( Configuration.IdentifierAttributeType, false ).Length > 0 )
                    //{
                    //    identifiers.Add( memberName );
                    //}
                    //else if ( conventionIdentifiers.Exists( x => x.ToLower() == memberName.ToLower() ) )
                    //{
                    //    identifiers.Add( memberName );
                    //}
                }
                else
                {
                    var propertyInfo = member as PropertyInfo;

                    if (propertyInfo != null)
                    {
                        //if ( propertyInfo.GetCustomAttributes( Configuration.IdentifierAttributeType, false ).Length > 0 )
                        //{
                        //    identifiers.Add( memberName );
                        //}
                        //else if ( conventionIdentifiers.Exists( x => x.ToLower() == memberName.ToLower() ) )
                        //{
                        //    identifiers.Add( memberName );
                        //}
                    }
                }
            }

            var typeMap = new EntityTypeMap(type, identifiers, fieldsAndProperties);

            return(typeMap);
        }