Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

renamed WithData extension method to WithQueryStringData

  • Loading branch information...
commit ba6ad00ffa70814d5f6fedf7c6c3294da705380f 1 parent 62eb164
@shashankshetty shashankshetty authored
View
16 src/FluentWebControls.Tests/Extensions/LinkDataExtensionsTest.cs
@@ -45,7 +45,7 @@ public class When_asked_to_add_queryParameter : LinkDataExtensionsTestBase
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_a_name_value_input_of_type_string()
{
- var link = LinkData.WithData("Name", "Value");
+ var link = LinkData.WithQueryStringData("Name", "Value");
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains("Name=Value").ShouldBeTrue();
}
@@ -53,7 +53,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_expression_that_returns_int()
{
- var link = LinkData.WithData(() => _item.ItemId);
+ var link = LinkData.WithQueryStringData(() => _item.ItemId);
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}={1}", Reflection.GetPropertyName(() => _item.ItemId), _item.ItemId)).ShouldBeTrue();
}
@@ -61,7 +61,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_expression_that_returns_int_and_separate_value_provided()
{
- var link = LinkData.WithData(() => _item.ItemId, 10);
+ var link = LinkData.WithQueryStringData(() => _item.ItemId, 10);
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}=10", Reflection.GetPropertyName(() => _item.ItemId))).ShouldBeTrue();
}
@@ -70,7 +70,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_expression_that_returns_nullable_int()
{
int? itemId = 5;
- var link = LinkData.WithData(() => itemId);
+ var link = LinkData.WithQueryStringData(() => itemId);
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}={1}", Reflection.GetPropertyName(() => itemId), itemId)).ShouldBeTrue();
}
@@ -80,7 +80,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
{
int? itemId = 5;
int? newValue = 10;
- var link = LinkData.WithData(() => itemId, newValue);
+ var link = LinkData.WithQueryStringData(() => itemId, newValue);
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}=10", Reflection.GetPropertyName(() => itemId))).ShouldBeTrue();
}
@@ -88,7 +88,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_expression_that_returns_string()
{
- var link = LinkData.WithData(() => _item.ItemName);
+ var link = LinkData.WithQueryStringData(() => _item.ItemName);
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}={1}", Reflection.GetPropertyName(() => _item.ItemName), _item.ItemName)).ShouldBeTrue();
}
@@ -96,7 +96,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_expression_that_returns_string_and_separate_value_provided()
{
- var link = LinkData.WithData(() => _item.ItemName, "Value");
+ var link = LinkData.WithQueryStringData(() => _item.ItemName, "Value");
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}=Value", Reflection.GetPropertyName(() => _item.ItemName))).ShouldBeTrue();
}
@@ -104,7 +104,7 @@ public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_
[Test]
public void Should_return_a_LinkData_With_query_parameter_added_to_the_link_for_an_object_that_contains_the_specified_property()
{
- var link = LinkData.WithData(_item, item => item.ItemId, item => item.ItemId.ToString());
+ var link = LinkData.WithQueryStringData(_item, item => item.ItemId, item => item.ItemId.ToString());
Assert.AreSame(LinkData, link);
LinkData.ToString().Contains(String.Format("{0}={1}", Reflection.GetPropertyName(() => _item.ItemId), _item.ItemId)).ShouldBeTrue();
}
View
18 src/FluentWebControls/Extensions/LinkDataExtensions.cs
@@ -39,25 +39,25 @@ public static LinkData VisibleIf(this LinkData buttonData, bool visible)
}
- public static LinkData WithData(this LinkData linkData, Expression<Func<string>> fieldNameAndValue)
+ public static LinkData WithQueryStringData(this LinkData linkData, Expression<Func<string>> fieldNameAndValue)
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldNameAndValue), fieldNameAndValue.Compile()());
return linkData;
}
- public static LinkData WithData(this LinkData linkData, Expression<Func<string>> fieldName, string value)
+ public static LinkData WithQueryStringData(this LinkData linkData, Expression<Func<string>> fieldName, string value)
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldName), value);
return linkData;
}
- public static LinkData WithData(this LinkData linkData, string fieldName, string value)
+ public static LinkData WithQueryStringData(this LinkData linkData, string fieldName, string value)
{
linkData.AddQueryStringData(fieldName, value);
return linkData;
}
- public static LinkData WithData(this LinkData linkData, IEnumerable<KeyValuePair<string, string>> items)
+ public static LinkData WithQueryStringData(this LinkData linkData, IEnumerable<KeyValuePair<string, string>> items)
{
foreach (var item in items)
{
@@ -66,32 +66,32 @@ public static LinkData WithData(this LinkData linkData, IEnumerable<KeyValuePair
return linkData;
}
- public static LinkData WithData<T>(this LinkData linkData, Expression<Func<T>> fieldNameAndValue) where T : struct
+ public static LinkData WithQueryStringData<T>(this LinkData linkData, Expression<Func<T>> fieldNameAndValue) where T : struct
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldNameAndValue), fieldNameAndValue.Compile()().ToString());
return linkData;
}
- public static LinkData WithData<T>(this LinkData linkData, Expression<Func<T>> fieldName, T value) where T : struct
+ public static LinkData WithQueryStringData<T>(this LinkData linkData, Expression<Func<T>> fieldName, T value) where T : struct
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldName), value.ToString());
return linkData;
}
- public static LinkData WithData<T>(this LinkData linkData, Expression<Func<T?>> fieldNameAndValue) where T : struct
+ public static LinkData WithQueryStringData<T>(this LinkData linkData, Expression<Func<T?>> fieldNameAndValue) where T : struct
{
var value = fieldNameAndValue.Compile()();
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldNameAndValue), value == null ? "" : value.ToString());
return linkData;
}
- public static LinkData WithData<T>(this LinkData linkData, Expression<Func<T?>> fieldName, T? value) where T : struct
+ public static LinkData WithQueryStringData<T>(this LinkData linkData, Expression<Func<T?>> fieldName, T? value) where T : struct
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldName), value == null ? "" : value.ToString());
return linkData;
}
- public static LinkData WithData<T, K>(this LinkData linkData, T source, Expression<Func<T, K>> fieldName, Func<T, string> fieldValue)
+ public static LinkData WithQueryStringData<T, K>(this LinkData linkData, T source, Expression<Func<T, K>> fieldName, Func<T, string> fieldValue)
{
linkData.AddQueryStringData(Reflection.GetPropertyName(fieldName), fieldValue(source));
return linkData;
View
8 src/FluentWebControls/GridData.cs
@@ -134,9 +134,9 @@ protected string BuildHeaderColumns()
sb.Append(Link
.To(ControllerName, ControllerExtension, ActionName)
.WithLinkText(column.ColumnHeader)
- .WithData(() => PagedListParameters.SortDirection, GetNextSortDirection(column.FieldName, column.IsDefaultSortColumn))
- .WithData(() => PagedListParameters.SortField, column.FieldName)
- .WithData(_filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue)))
+ .WithQueryStringData(() => PagedListParameters.SortDirection, GetNextSortDirection(column.FieldName, column.IsDefaultSortColumn))
+ .WithQueryStringData(() => PagedListParameters.SortField, column.FieldName)
+ .WithQueryStringData(_filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue)))
.WithId("th" + columnNumber)
);
break;
@@ -171,7 +171,7 @@ private void BuildRow(int rowId, StringBuilder sb)
sb.Append(Link
.To(ControllerName, ControllerExtension, column.ActionName)
.WithLinkText(column.ActionName)
- .WithData(column.FieldName, column[rowId]));
+ .WithQueryStringData(column.FieldName, column[rowId]));
break;
default:
throw new ArgumentOutOfRangeException();
View
1  src/FluentWebControls/LinkData.cs
@@ -201,6 +201,7 @@ public override string ToString()
{
sb.Append(CssClass.CreateQuotedAttribute("class"));
}
+ sb.Append(Data);
if (MouseOverText != null)
{
sb.Append(MouseOverText.CreateQuotedAttribute("title"));
View
40 src/FluentWebControls/PagedGridData.cs
@@ -48,41 +48,41 @@ public override string ToString()
.WithMouseOverText("First Page")
.WithCssClass("linkHighlight")
.DisabledIf(PagedListParameters.PageNumber == 1)
- .WithData(() => PagedListParameters.PageNumber, 1)
- .WithData(() => PagedListParameters.PageSize)
- .WithData(() => PagedListParameters.SortDirection)
- .WithData(() => PagedListParameters.SortField)
- .WithData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
+ .WithQueryStringData(() => PagedListParameters.PageNumber, 1)
+ .WithQueryStringData(() => PagedListParameters.PageSize)
+ .WithQueryStringData(() => PagedListParameters.SortDirection)
+ .WithQueryStringData(() => PagedListParameters.SortField)
+ .WithQueryStringData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
Fluent.LinkTo(ControllerName, ControllerExtension, ActionName)
.WithLinkText("<")
.WithMouseOverText("Previous Page")
.WithCssClass("linkHighlight")
.DisabledIf(PagedListParameters.PageNumber == 1)
- .WithData(() => PagedListParameters.PageNumber, PagedListParameters.PageNumber - 1)
- .WithData(() => PagedListParameters.PageSize)
- .WithData(() => PagedListParameters.SortDirection)
- .WithData(() => PagedListParameters.SortField)
- .WithData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
+ .WithQueryStringData(() => PagedListParameters.PageNumber, PagedListParameters.PageNumber - 1)
+ .WithQueryStringData(() => PagedListParameters.PageSize)
+ .WithQueryStringData(() => PagedListParameters.SortDirection)
+ .WithQueryStringData(() => PagedListParameters.SortField)
+ .WithQueryStringData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
Fluent.LinkTo(ControllerName, ControllerExtension, ActionName)
.WithLinkText(">")
.WithMouseOverText("Next Page")
.WithCssClass("linkHighlight")
.DisabledIf(PagedListParameters.PageNumber == LastPage)
- .WithData(() => PagedListParameters.PageNumber, PagedListParameters.PageNumber + 1)
- .WithData(() => PagedListParameters.PageSize)
- .WithData(() => PagedListParameters.SortDirection)
- .WithData(() => PagedListParameters.SortField)
- .WithData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
+ .WithQueryStringData(() => PagedListParameters.PageNumber, PagedListParameters.PageNumber + 1)
+ .WithQueryStringData(() => PagedListParameters.PageSize)
+ .WithQueryStringData(() => PagedListParameters.SortDirection)
+ .WithQueryStringData(() => PagedListParameters.SortField)
+ .WithQueryStringData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
Fluent.LinkTo(ControllerName, ControllerExtension, ActionName)
.WithLinkText(">>")
.WithMouseOverText("Last Page")
.WithCssClass("linkHighlight")
.DisabledIf(PagedListParameters.PageNumber == LastPage)
- .WithData(() => PagedListParameters.PageNumber, LastPage)
- .WithData(() => PagedListParameters.PageSize)
- .WithData(() => PagedListParameters.SortDirection)
- .WithData(() => PagedListParameters.SortField)
- .WithData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
+ .WithQueryStringData(() => PagedListParameters.PageNumber, LastPage)
+ .WithQueryStringData(() => PagedListParameters.PageSize)
+ .WithQueryStringData(() => PagedListParameters.SortDirection)
+ .WithQueryStringData(() => PagedListParameters.SortField)
+ .WithQueryStringData(Filters.Select(f => new KeyValuePair<string, string>(((IWebControl)f).Id, ((IDropDownListData)f).SelectedValue))),
Fluent.TextBoxFor(PagedListParameters, x => x.PageNumber.ToString(), x => x.PageNumber)
.MinValue(1)
.MaxValue(LastPage)
Please sign in to comment.
Something went wrong with that request. Please try again.