For example I have the following class:
public class PublishFacebookOpenGraphActionRequest
{
public FacebookOpenGraphActions Action { get; private set; }
public FacebookOpenGraphObjects ObjectType { get; private set; }
public Uri Url { get; private set; }
public Uri Image { get; private set; }
}
And I would like to be able to generate something like this from the current set of properties:
public class PublishFacebookOpenGraphAction
{
public FacebookOpenGraphActions Action { get; private set; }
public FacebookOpenGraphObjects ObjectType { get; private set; }
public Uri Url { get; private set; }
public Uri Image { get; private set; }
public PublishFacebookOpenGraphAction WithAction(FacebookOpenGraphActions action)
{
this.Action = action;
return this;
}
public PublishFacebookOpenGraphAction WithObjectType(FacebookOpenGraphObjects objectType)
{
this.ObjectType = objectType;
return this;
}
public PublishFacebookOpenGraphAction WithUrl(Uri url)
{
this.Url = url;
return this;
}
public PublishFacebookOpenGraphAction WithImage(Uri image)
{
this.Image = image;
return this;
}
}
I do not have a conversion from all members of PublishFacebookOpenGraphActionRequest to a fluent interface.
But maybe an half-automated generation of a fluent property-WithMember-pair is also a small step forward. This is possible with a ReSharper Live Template.
I have an example:
You can create the following code with that Live Template:
by just typing
fluentProp+ ENTER and entering property name and its type.