Browse Source

rm ludbo; added delegate to configure utils

tags/v0.1.0
Robin Thoni 8 years ago
parent
commit
6c670d9b38

+ 4
- 9
Luticate2.Auth/Controllers/LuAuthExtensions.cs View File

@@ -1,21 +1,18 @@
1
-using System.Collections.Generic;
2
-using Luticate2.Auth.Business;
1
+using Luticate2.Auth.Business;
3 2
 using Luticate2.Auth.DataAccess;
4 3
 using Luticate2.Auth.Middlewares;
5 4
 using Luticate2.Utils.Controllers;
6
-using Luticate2.Utils.Dbo.OrderBy;
7 5
 using Microsoft.AspNetCore.Builder;
8 6
 using Microsoft.AspNetCore.Http;
9
-using Microsoft.AspNetCore.Mvc;
10 7
 using Microsoft.Extensions.DependencyInjection;
11 8
 
12 9
 namespace Luticate2.Auth.Controllers
13 10
 {
14 11
     public static class LuAuthExtensions
15 12
     {
16
-        public static IServiceCollection AddLuticateAuth(this IServiceCollection services)
13
+        public static IServiceCollection AddLuticateAuth(this IServiceCollection services, LuUtilsExtensions.LuOptionsDelegate optionsDelegate)
17 14
         {
18
-            services.AddLuticatUtils();
15
+            services.AddLuticateUtils(optionsDelegate);
19 16
 
20 17
             services.AddSingleton<LuGroupsController>();
21 18
             services.AddSingleton<LuGroupsBusiness>();
@@ -30,9 +27,7 @@ namespace Luticate2.Auth.Controllers
30 27
 
31 28
         public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
32 29
         {
33
-            builder.AddLuticatUtils();
34
-//            builder.AddApplicationPart(typeof(LuController).GetTypeInfo().Assembly)
35
-//                .AddControllersAsServices();
30
+            builder.AddLuticateUtils();
36 31
             return builder;
37 32
         }
38 33
 

+ 1
- 1
Luticate2.Auth/Dbo/Groups/LuGroupsAddDbo.cs View File

@@ -3,7 +3,7 @@ using Luticate2.Utils.Dbo.Basic;
3 3
 
4 4
 namespace Luticate2.Auth.Dbo.Groups
5 5
 {
6
-    public class LuGroupsAddDbo : LuDbo
6
+    public class LuGroupsAddDbo
7 7
     {
8 8
         public string Name { get; set; }
9 9
     }

+ 1
- 1
Luticate2.Auth/Dbo/Groups/LuGroupsDbo.cs View File

@@ -3,7 +3,7 @@ using Luticate2.Utils.Dbo.Basic;
3 3
 
4 4
 namespace Luticate2.Auth.Dbo.Groups
5 5
 {
6
-    public class LuGroupsDbo : LuDbo
6
+    public class LuGroupsDbo
7 7
     {
8 8
         public string Id { get; set; }
9 9
 

+ 1
- 1
Luticate2.Auth/Dbo/Users/UsersDbo.cs View File

@@ -3,7 +3,7 @@ using Luticate2.Utils.Dbo.Basic;
3 3
 
4 4
 namespace Luticate2.Auth.Dbo.Users
5 5
 {
6
-    public class UsersDbo : LuDbo
6
+    public class UsersDbo
7 7
     {
8 8
 
9 9
     }

+ 4
- 2
Luticate2.Utils/Controllers/LuController.cs View File

@@ -1,4 +1,5 @@
1
-using System.Collections.Generic;
1
+using System;
2
+using System.Collections.Generic;
2 3
 using System.Threading;
3 4
 using Luticate2.Utils.Dbo;
4 5
 using Luticate2.Utils.Dbo.Basic;
@@ -22,7 +23,8 @@ namespace Luticate2.Utils.Controllers
22 23
                 {
23 24
                     code = 200,
24 25
                     data = result.Data,
25
-                    message = null
26
+                    message = null,
27
+                    Version = LuUtilsExtensions.Options.Version
26 28
                 };
27 29
             }
28 30
             throw new LuResultException(result.To<object>());

+ 9
- 4
Luticate2.Utils/Controllers/LuUtilsExtensions.cs View File

@@ -1,5 +1,5 @@
1 1
 using System.Collections.Generic;
2
-using Luticate2.Utils.Dbo;
2
+using Luticate2.Utils.Dbo.Basic;
3 3
 using Luticate2.Utils.Dbo.OrderBy;
4 4
 using Luticate2.Utils.Dbo.Result;
5 5
 using Luticate2.Utils.Middlewares;
@@ -12,13 +12,18 @@ namespace Luticate2.Utils.Controllers
12 12
 {
13 13
     public static class LuUtilsExtensions
14 14
     {
15
-        public static IServiceCollection AddLuticatUtils(this IServiceCollection services)
16
-        {
15
+        public delegate void LuOptionsDelegate(LuOptionsDbo options);
16
+
17
+        public static LuOptionsDbo Options { get; private set; }
17 18
 
19
+        public static IServiceCollection AddLuticateUtils(this IServiceCollection services, LuOptionsDelegate optionsDelegate)
20
+        {
21
+            Options = new LuOptionsDbo();
22
+            optionsDelegate(Options);
18 23
             return services;
19 24
         }
20 25
 
21
-        public static IMvcBuilder AddLuticatUtils(this IMvcBuilder builder)
26
+        public static IMvcBuilder AddLuticateUtils(this IMvcBuilder builder)
22 27
         {
23 28
             builder.Services.Configure<MvcOptions>(
24 29
                 options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));

+ 2
- 0
Luticate2.Utils/Dbo/Basic/LuApiWrapperDbo.cs View File

@@ -7,5 +7,7 @@
7 7
         public string message { get; set; }
8 8
 
9 9
         public T data { get; set; }
10
+
11
+        public string Version { get; set; }
10 12
     }
11 13
 }

+ 1
- 1
Luticate2.Utils/Dbo/Basic/LuBoxedValueDbo.cs View File

@@ -1,6 +1,6 @@
1 1
 namespace Luticate2.Utils.Dbo.Basic
2 2
 {
3
-    public class LuBoxedValueDbo<T> : LuDbo
3
+    public class LuBoxedValueDbo<T>
4 4
     {
5 5
         public T Value { get; set; }
6 6
     }

+ 0
- 7
Luticate2.Utils/Dbo/Basic/LuDbo.cs View File

@@ -1,7 +0,0 @@
1
-namespace Luticate2.Utils.Dbo.Basic
2
-{
3
-    public class LuDbo
4
-    {
5
-
6
-    }
7
-}

+ 7
- 0
Luticate2.Utils/Dbo/Basic/LuOptionsDbo.cs View File

@@ -0,0 +1,7 @@
1
+namespace Luticate2.Utils.Dbo.Basic
2
+{
3
+    public class LuOptionsDbo
4
+    {
5
+        public string Version { get; set; }
6
+    }
7
+}

+ 1
- 1
Luticate2.Utils/Dbo/Basic/LuPaginatedDbo.cs View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace Luticate2.Utils.Dbo.Basic
4 4
 {
5
-    public class LuPaginatedDbo<TDbo> : LuDbo
5
+    public class LuPaginatedDbo<TDbo>
6 6
     {
7 7
         public long Count { get; set; }
8 8
 

+ 4
- 2
Luticate2.Utils/Middlewares/LuExceptionMiddleware.cs View File

@@ -34,7 +34,8 @@ namespace Luticate2.Utils.Middlewares
34 34
                 {
35 35
                     code = e.Result.GetHttpCode(),
36 36
                     data = null,
37
-                    message = e.Result.PublicDetails ?? e.Result.GetHttpString()
37
+                    message = e.Result.PublicDetails ?? e.Result.GetHttpString(),
38
+                    Version = LuUtilsExtensions.Options.Version
38 39
                 })).ConfigureAwait(false);
39 40
             }
40 41
             catch (Exception e)//TODO
@@ -46,7 +47,8 @@ namespace Luticate2.Utils.Middlewares
46 47
                 {
47 48
                     code = 500,
48 49
                     data = null,
49
-                    message = "Internal Error"
50
+                    message = "Internal Error",
51
+                    Version = LuUtilsExtensions.Options.Version
50 52
                 })).ConfigureAwait(false);
51 53
             }
52 54
         }

+ 1
- 1
WebTest/Startup.cs View File

@@ -38,7 +38,7 @@ namespace WebTest
38 38
             // Add framework services.
39 39
             services.AddApplicationInsightsTelemetry(Configuration);
40 40
 
41
-            services.AddLuticateAuth();
41
+            services.AddLuticateAuth(options => options.Version = "dev");
42 42
 
43 43
             services.AddTransient<PkGuidBusiness>();
44 44
             services.AddTransient<LuUtilsPkGuidDataAccess>();

Loading…
Cancel
Save