I have been trying to design a fluent interface for one of my frameworks and it seems that I can't understand one piece of the puzzle. I understand that I can use interfaces and classes to kind of drive which methods I want to call. However consider the following scenario.
Lets Say I have a Person class and I want to be able to do something like
Person.WithName("Steve").WithAge(18).Save();
Simmilarly I also want the caller of my API to do something like
Person.WithName("Steve").Save();
or
Person.WithAge(18).Save();
But I don't want the user to call the save method alone like
Person.Save();
Now if I want to design such an API how can I implement it? If i return instance of Person class from WithName and WithAge methods then I have to put the Save method in the Person class as well which means user can call it directly.