Trying to create a simple noddy example so that I can build my next project using fluent interfaces. I need to provide the user of my dll with an intuitive step by step way of building a class.
Question. I would like the user only to see Initialise when the first start then step1 then step2 and then end?How can I do it?
This is my attempt which As soon as you put the "." you see everything,then they hide.
class Program
{
static void Main(string[] args)
{
IEnd builder = new StepBuilder()
.Initialize()
.LoadStuff()
.Validate()
.End();
}
}
public class StepBuilder : IInitialize,
IStep1,
IStep2,
IStep3,
IEnd
{
public IStep1 Initialize()
{
return this;
}
public IStep2 LoadStuff()
{
return this; ;
}
public IStep3 Validate()
{
return this;
}
public IEnd End()
{
return this;
}
public bool Save()
{
return true;
}
}
public class Step
{
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
}
public interface IInitialize
{
IStep1 Initialize();
}
public interface IStep1
{
IStep2 LoadStuff();
}
public interface IStep2
{
IStep3 Validate ();
}
public interface IStep3
{
IEnd End();
}
public interface IEnd
{
bool Save();
}
}
any suggestions or good link on building progressive fluent interfaces?