/// <summary>
        /// Enumerate this class' properties using reflection, create PropertyMappings
        /// for them and add them to the PropertyMappings.
        /// </summary>
        private static void inspectProperties(ClassMapping me)
        {
            foreach (var property in ReflectionHelper.FindPublicProperties(me.NativeType))
            {
                // Skip properties that are marked as NotMapped
                if (ReflectionHelper.GetAttribute <NotMappedAttribute>(property) != null)
                {
                    continue;
                }

                var propMapping = PropertyMapping.Create(property);
                var propKey     = propMapping.Name.ToUpperInvariant();

                if (me._propMappings.ContainsKey(propKey))
                {
                    throw Error.InvalidOperation($"Class has multiple properties that are named '{propKey}'. The property name must be unique");
                }

                me._propMappings.Add(propKey, propMapping);

                // Keep a pointer to this property if this is a primitive value element ("Value" in primitive types)
                if (propMapping.RepresentsValueElement)
                {
                    me.PrimitiveValueProperty = propMapping;
                }
            }

            me._orderedMappings = me._propMappings.Values.OrderBy(prop => prop.Order).ToList();
        }
示例#2
0
        /// <summary>
        /// Enumerate this class' properties using reflection, create PropertyMappings
        /// for them and add them to the PropertyMappings.
        /// </summary>
        private static void inspectProperties(ClassMapping me)
        {
            foreach (var property in ReflectionHelper.FindPublicProperties(me.NativeType))
            {
                // Skip properties that are marked as NotMapped
                if (ReflectionHelper.GetAttribute <NotMappedAttribute>(property) != null)
                {
                    continue;
                }

                var propMapping = PropertyMapping.Create(property);

                me._propMappings.Add(propMapping.Name.ToUpperInvariant(), propMapping);

                // Keep a pointer to this property if this is a primitive value element ("Value" in primitive types)
                if (propMapping.RepresentsValueElement)
                {
                    me.PrimitiveValueProperty = propMapping;
                }
            }

            me._orderedMappings = me._propMappings.Values.OrderBy(prop => prop.Order).ToList();
        }