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
-using System.Collections.Generic;
2
-using Luticate2.Auth.Business;
1
+using Luticate2.Auth.Business;
3
 using Luticate2.Auth.DataAccess;
2
 using Luticate2.Auth.DataAccess;
4
 using Luticate2.Auth.Middlewares;
3
 using Luticate2.Auth.Middlewares;
5
 using Luticate2.Utils.Controllers;
4
 using Luticate2.Utils.Controllers;
6
-using Luticate2.Utils.Dbo.OrderBy;
7
 using Microsoft.AspNetCore.Builder;
5
 using Microsoft.AspNetCore.Builder;
8
 using Microsoft.AspNetCore.Http;
6
 using Microsoft.AspNetCore.Http;
9
-using Microsoft.AspNetCore.Mvc;
10
 using Microsoft.Extensions.DependencyInjection;
7
 using Microsoft.Extensions.DependencyInjection;
11
 
8
 
12
 namespace Luticate2.Auth.Controllers
9
 namespace Luticate2.Auth.Controllers
13
 {
10
 {
14
     public static class LuAuthExtensions
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
             services.AddSingleton<LuGroupsController>();
17
             services.AddSingleton<LuGroupsController>();
21
             services.AddSingleton<LuGroupsBusiness>();
18
             services.AddSingleton<LuGroupsBusiness>();
30
 
27
 
31
         public static IMvcBuilder AddLuticateAuth(this IMvcBuilder builder)
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
             return builder;
31
             return builder;
37
         }
32
         }
38
 
33
 

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

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

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

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

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

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

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

1
 using System.Collections.Generic;
1
 using System.Collections.Generic;
2
-using Luticate2.Utils.Dbo;
2
+using Luticate2.Utils.Dbo.Basic;
3
 using Luticate2.Utils.Dbo.OrderBy;
3
 using Luticate2.Utils.Dbo.OrderBy;
4
 using Luticate2.Utils.Dbo.Result;
4
 using Luticate2.Utils.Dbo.Result;
5
 using Luticate2.Utils.Middlewares;
5
 using Luticate2.Utils.Middlewares;
12
 {
12
 {
13
     public static class LuUtilsExtensions
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
             return services;
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
             builder.Services.Configure<MvcOptions>(
28
             builder.Services.Configure<MvcOptions>(
24
                 options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));
29
                 options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));

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

7
         public string message { get; set; }
7
         public string message { get; set; }
8
 
8
 
9
         public T data { get; set; }
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
 namespace Luticate2.Utils.Dbo.Basic
1
 namespace Luticate2.Utils.Dbo.Basic
2
 {
2
 {
3
-    public class LuBoxedValueDbo<T> : LuDbo
3
+    public class LuBoxedValueDbo<T>
4
     {
4
     {
5
         public T Value { get; set; }
5
         public T Value { get; set; }
6
     }
6
     }

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

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

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

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

34
                 {
34
                 {
35
                     code = e.Result.GetHttpCode(),
35
                     code = e.Result.GetHttpCode(),
36
                     data = null,
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
                 })).ConfigureAwait(false);
39
                 })).ConfigureAwait(false);
39
             }
40
             }
40
             catch (Exception e)//TODO
41
             catch (Exception e)//TODO
46
                 {
47
                 {
47
                     code = 500,
48
                     code = 500,
48
                     data = null,
49
                     data = null,
49
-                    message = "Internal Error"
50
+                    message = "Internal Error",
51
+                    Version = LuUtilsExtensions.Options.Version
50
                 })).ConfigureAwait(false);
52
                 })).ConfigureAwait(false);
51
             }
53
             }
52
         }
54
         }

+ 1
- 1
WebTest/Startup.cs View File

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

Loading…
Cancel
Save