Is there an easy “built-in-way” of combining paths for using them as a single parameter?
I use an own Implementation called SpringPathCombiner to do the following:
<property name="CombinedPath">
<object type="SpringExt.SpringPathCombiner, SpringExt">
<constructor-arg name="path1">
<object factory-method="GetBasePath" factory-object="MyConfig" />
</constructor-arg>
<constructor-arg name="path2" value="Temp" />
</object>
</property>
This will set the Combined path to the combination of the return value of the
method GetBasePath together with “Temp”, e.g. C:\MyBasePath\Temp.
The SpringPathCombiner class itself is very simple:
public class SpringPathCombiner
{
private readonly string path;
public SpringPathCombiner(string path1, string path2)
{
path = Path.Combine(path1, path2);
}
public static implicit operator string(SpringPathCombiner combiner)
{
return combiner.path;
}
public override string ToString()
{
return path;
}
}
But I don’t want to have code duplication and I think there must by a way to do this kind of job with the things brought by Spring itself. Anyone knows a way how to do this without an own implementation, e.g. using Path.Combine directly?
Have you tried using an expression? For example:
You can easily use properties of other objects too: