Catel.Data.CatelTypeInfo.FindCatelFields C# (CSharp) Method

FindCatelFields() private method

Finds the fields that represent a PropertyData.
One ore more fields are not declared correctly.
private FindCatelFields ( Type type ) : IEnumerable
type System.Type The type.
return IEnumerable
        private IEnumerable<PropertyData> FindCatelFields(Type type)
        {
            // CTL-212: Generic types are not supported for FieldInfo.GetValue
            if (type.ContainsGenericParametersEx())
            {
                return new PropertyData[] { };
            }

            PreventWrongDeclaredFields(type);

            // Fields - actual addition
            var foundFields = new List<PropertyData>();

            var fields = new List<FieldInfo>();
            fields.AddRange(type.GetFieldsEx(BindingFlagsHelper.GetFinalBindingFlags(true, true, false)));
            foreach (var field in fields)
            {
                if (field.FieldType == typeof(PropertyData))
                {
                    var propertyValue = (field.IsStatic ? field.GetValue(null) : field.GetValue(this)) as PropertyData;
                    if (propertyValue != null)
                    {
                        foundFields.Add(propertyValue);
                    }
                }
            }

            return foundFields;
        }