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

FeatureRequest, ActLike with possibility to map method names #26

Open
sjoerd222888 opened this issue Oct 14, 2017 · 1 comment
Open

Comments

@sjoerd222888
Copy link

Hi

I think it is not yet possible what I would like to do. Let's assume I have

public class MyAdder{
    public double Add(double a, double b){
        return a + b;
    }
}

and an interface

public interface ISumCalculater{
    double Sum(double value1, double value2);
}

What I would like to be able to do is:

MyAdder adder = new MyAdder();
ISumCalculater calculator = adder.ActLike<ISumCalculater>().MapMethod("Add", "Sum");
double result = calculator.Sum(1.0, 2.0);

So I would like to have the possibility to have different method names in the interface and the implementation and still have the possibility to use ActLike<>. So I could use implementations which are compatible on the 'logical level' (however that should be called), but not on the naming level (which from a functional point of view is secondary; whether I call a car a "car", "voiture" or "автомобиль" does not change its behavior and functionality).

Now my question is whether this (by some way that I overlooked) is already possible in your library. If not then I would be interested to know whether this library could be extended to support that scenario (not only technically but also whether it would fit "the intention" of the library in your opinion).

Potentially this also interesting of course for properties.

@jbtule
Copy link
Member

jbtule commented Oct 24, 2017

While there isn't a dynamic map feature already in impromptu interface (there is a static map feature, https://github.com/ekonbenefits/impromptu-interface/blob/master/ImpromptuInterface/src/Attributes/AliasAttribute.cs).

Implementing a dynamic mapper on your own wouldn't be that hard using Dynamitey.DynamicObjects.BaseForwarder https://github.com/ekonbenefits/dynamitey/blob/master/Dynamitey/DynamicObjects/BaseForwarder.cs

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