Skip to content

Commit 109c9ff

Browse files
committed
Added public JsonExtensions.ToJsonString and ComboboxItemDtoExtensions.ToSelectListItem methods.
1 parent 486075b commit 109c9ff

File tree

10 files changed

+36
-9
lines changed

10 files changed

+36
-9
lines changed

src/Abp.Web.Mvc/Abp.Web.Mvc.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<Reference Include="System.Xml" />
9090
</ItemGroup>
9191
<ItemGroup>
92+
<Compile Include="Application\Services\Dto\ComboboxItemDtoExtensions.cs" />
9293
<Compile Include="Web\Mvc\Authorization\AbpMvcAuthorizeAttribute.cs" />
9394
<Compile Include="Web\Mvc\Controllers\AbpController.cs" />
9495
<Compile Include="Web\Mvc\Controllers\AbpHandleErrorAttribute.cs" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Web.Mvc;
2+
3+
namespace Abp.Application.Services.Dto
4+
{
5+
public static class ComboboxItemDtoExtensions
6+
{
7+
public static SelectListItem ToSelectListItem(this ComboboxItemDto comboboxItem)
8+
{
9+
return new SelectListItem
10+
{
11+
Value = comboboxItem.Value,
12+
Text = comboboxItem.DisplayText,
13+
Selected = comboboxItem.IsSelected
14+
};
15+
}
16+
}
17+
}

src/Abp.Web/Web/Features/FeaturesScriptManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public async Task<string> GetScriptAsync()
6767
//TODO: Other feature properties and custom attributes
6868

6969
//TODO: Consider to remove inputType since it's only needed while editing!
70-
script.AppendLine(" inputType: " + JsonHelper.ConvertToJson(feature.InputType, true, true));
70+
script.AppendLine(" inputType: " + feature.InputType.ToJsonString(true, true));
7171

7272
script.Append(" }");
7373

src/Abp.Web/Web/Navigation/NavigationScriptManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private static void AppendMenu(StringBuilder sb, UserMenu menu)
5858

5959
if (menu.CustomData != null)
6060
{
61-
sb.AppendLine(" customData: " + JsonHelper.ConvertToJson(menu.CustomData, true) + ",");
61+
sb.AppendLine(" customData: " + menu.CustomData.ToJsonString(true) + ",");
6262
}
6363

6464
sb.Append(" items: ");
@@ -108,7 +108,7 @@ private static void AppendMenuItem(int indentLength, StringBuilder sb, UserMenuI
108108

109109
if (menuItem.CustomData != null)
110110
{
111-
sb.AppendLine(new string(' ', indentLength + 4) + "customData: " + JsonHelper.ConvertToJson(menuItem.CustomData, true) + ",");
111+
sb.AppendLine(new string(' ', indentLength + 4) + "customData: " + menuItem.CustomData.ToJsonString(true) + ",");
112112
}
113113

114114
sb.Append(new string(' ', indentLength + 4) + "items: [");

src/Abp/Abp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<Compile Include="Runtime\Caching\Configuration\CachingConfiguration.cs" />
155155
<Compile Include="Runtime\Caching\Configuration\ICacheConfigurator.cs" />
156156
<Compile Include="Runtime\Caching\Configuration\ICachingConfiguration.cs" />
157-
<Compile Include="Json\JsonHelper.cs" />
157+
<Compile Include="Json\JsonExtensions.cs" />
158158
<Compile Include="NameValue.cs" />
159159
<Compile Include="Application\Services\Dto\NameValueDto.cs" />
160160
<Compile Include="Application\Services\Dto\NullableIdInput.cs" />

src/Abp/AbpConsts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static class AbpConsts
88
/// <summary>
99
/// Current version of the ABP.
1010
/// </summary>
11-
public const string CurrentVersion = "0.7.1.0";
11+
public const string CurrentVersion = "0.7.1.1";
1212

1313
/// <summary>
1414
/// Localization source name of ASP.NET Boilerplate framework.

src/Abp/Application/Services/Dto/ComboboxItemDto.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public class ComboboxItemDto : IDto
1818
/// </summary>
1919
public string DisplayText { get; set; }
2020

21+
/// <summary>
22+
/// Is selected?
23+
/// </summary>
24+
public bool IsSelected { get; set; }
25+
2126
/// <summary>
2227
/// Creates a new <see cref="ComboboxItemDto"/>.
2328
/// </summary>

src/Abp/Auditing/AuditingInterceptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private string ConvertArgumentsToJson(IInvocation invocation)
140140
dictionary[parameter.Name] = argument;
141141
}
142142

143-
return JsonHelper.ConvertToJson(dictionary, true);
143+
return dictionary.ToJsonString(true);
144144
}
145145
catch (Exception ex)
146146
{

src/Abp/Authorization/Permission.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public sealed class Permission
5050
/// <summary>
5151
/// Depended feature(s) of this permission.
5252
/// </summary>
53-
public IFeatureDependency DependedFeature { get; }
53+
public IFeatureDependency DependedFeature { get; set; }
5454

5555
/// <summary>
5656
/// List of child permissions. A child permission can be granted only if parent is granted.

src/Abp/Json/JsonHelper.cs renamed to src/Abp/Json/JsonExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
namespace Abp.Json
55
{
6-
internal static class JsonHelper
6+
public static class JsonExtensions
77
{
8-
public static string ConvertToJson(object obj, bool camelCase = false, bool indented = false)
8+
/// <summary>
9+
/// Converts given object to JSON string.
10+
/// </summary>
11+
/// <returns></returns>
12+
public static string ToJsonString(this object obj, bool camelCase = false, bool indented = false)
913
{
1014
var options = new JsonSerializerSettings();
1115

0 commit comments

Comments
 (0)