Fluent Interface for WebRequest object
WebRequest object is usually used by us. That is a reason I create this project. I also used this class but I feel it is very un-readable code. How do you feel if
you code it have something like that:
var url = "http://www.bbc.co.uk/search/news/";
url += BuiltParammetters();
objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.CookieContainer = myContainer;
Certainly it will be good, but we can make it for better as:
var result = RequestSubmitter.GetInstance()
.WithUrl("http://www.bbc.co.uk/search/news/")
.Item.WithNameIs("q").ValueIs("Queen Elizabeth II")
.ConnectWith.Item.WithNameIs("video").ValueIs("on")
.ConnectWith.Item.WithNameIs("audio").ValueIs("on")
.ConnectWith.Item.WithNameIs("text").ValueIs("on")
.WithRequestTypeIs(RequestMethodType.Post)
.BuildUrl()
.GetDataFromUrl();
And that is a purpose of this project as well.
I love fluent and love semantic that express through
Fluent Interface