Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove if properties or their types has got ExcludeProxy Attribute #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion WebApiProxy.Server/MetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,14 @@ private void AddModelDefinition(Type classToDef)
var properties = classToDef.IsGenericType
? classToDef.GetGenericTypeDefinition().GetProperties()
: classToDef.GetProperties();


// remove if properties or their types has got ExcludeProxy Attribute (or dummy name)
properties = properties.Where(x =>
!x.CustomAttributes.Any(z => z.AttributeType.Name.Contains("ExcludeProxy")) && // Property
!x.PropertyType.CustomAttributes.Any(y => y.AttributeType.Name.Contains("ExcludeProxy")) // Type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid magic strings where possible.

An idea is to either compare to nameof(ExcludeProxy) or just compare where types contain typeof(ExcludeProxy)

).ToArray(); // Clear and Nice :)


model.Properties = from property in properties
select new ModelProperty
{
Expand Down