S
shapper
Hello,
I have the following method on a open source library:
public void MapFrom(Func<TSource, object> sourceMember) {
_propertyMap.AssignCustomValueResolver(new
DelegateBasedResolver<TSource>(sourceMember));
}
Which is used as follows:
MapFrom(s => s.File.InputStream)
I would like to add a condition to it as follows:
public void MapFrom(Func<TSource, object> sourceMember, bool
condition) {
if (condition)
_propertyMap.Ignore();
else
_propertyMap.AssignCustomValueResolver(new
DelegateBasedResolver<TSource>(sourceMember));
}
But that I could use as follows:
MapFrom(s => s.File.InputStream, s.FileInputStream.ContenLenght == 0)
So I would like to also use the object s in the condition parameter.
I tried to replace "bool condition" by "Func<TSource, bool> condition"
But then I am not sure how to test its value inside the method.
How can I do this?
Thanks,
Miguel
I have the following method on a open source library:
public void MapFrom(Func<TSource, object> sourceMember) {
_propertyMap.AssignCustomValueResolver(new
DelegateBasedResolver<TSource>(sourceMember));
}
Which is used as follows:
MapFrom(s => s.File.InputStream)
I would like to add a condition to it as follows:
public void MapFrom(Func<TSource, object> sourceMember, bool
condition) {
if (condition)
_propertyMap.Ignore();
else
_propertyMap.AssignCustomValueResolver(new
DelegateBasedResolver<TSource>(sourceMember));
}
But that I could use as follows:
MapFrom(s => s.File.InputStream, s.FileInputStream.ContenLenght == 0)
So I would like to also use the object s in the condition parameter.
I tried to replace "bool condition" by "Func<TSource, bool> condition"
But then I am not sure how to test its value inside the method.
How can I do this?
Thanks,
Miguel