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

Filtering methods #18

Closed
urbanmichal opened this issue Nov 4, 2016 · 5 comments
Closed

Filtering methods #18

urbanmichal opened this issue Nov 4, 2016 · 5 comments

Comments

@urbanmichal
Copy link

Hi guys,

Is there any way to generate methods, which name doesn't starts with "Begin" or "End" phrase?

Pseudocode:

.ExportAsInterfaces(proxyInterfaces, conf => conf.WithPublicMethods(publicMethod =>
!publicMethod.GetType().Name.StartsWith("Begin")
&&
!publicMethod.GetType().Name.StartsWith("End")));

@pavel-b-novikov
Copy link
Member

pavel-b-novikov commented Nov 4, 2016

var types = new Type[0]; // fetch desired types by yourself
builder.ExportAsInterfaces(types,
    c => c.WithMethods(
        x => x.IsPublic && !(x.Name.StartsWith("Begin") || x.Name.StartsWith("End")),
        x => x.Returns<string>()
        )
    );

@urbanmichal
Copy link
Author

Work like a charm, thank you :) Działa pięknie, ja ponimaju trochę też ;) Closing!

@urbanmichal
Copy link
Author

urbanmichal commented Nov 4, 2016

I've got minor problem with this solution:

x => x.Returns<string>()

Now every interface has a hard-coded string return type. Could we keep proper return type?

@pavel-b-novikov
Copy link
Member

pavel-b-novikov commented Nov 4, 2016

x => x.Returns<string>() - is just sample that you can configure export settings for bunch of methods. You can entirely remove this parameter of .WithMethods to make it simply export methods without additional actions.
Like that:

var types = new Type[0]; // fetch desired types by yourself
builder.ExportAsInterfaces(types,
    c => c.WithMethods( x => x.IsPublic && !(x.Name.StartsWith("Begin") || x.Name.StartsWith("End")))
    );

@urbanmichal
Copy link
Author

Of course... Great, thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants