Browse Source

LuObjectConverter stuff

develop
Robin Thoni 6 years ago
parent
commit
4178122311
23 changed files with 367 additions and 121 deletions
  1. 11
    3
      .idea/.idea.luticate2/.idea/contentModel.xml
  2. 8
    7
      Luticate2.Auth.Tests/Business/ExpressionConverter/ExpressionConverterTests.cs
  3. 8
    8
      Luticate2.Auth.Tests/Business/ExpressionConverter/Objects.cs
  4. 45
    10
      Luticate2.Auth.Tests/Business/ObjectConverter/ObjectConverterTests.cs
  5. 11
    10
      Luticate2.Auth.Tests/Business/ObjectConverter/Objects.cs
  6. 12
    9
      Luticate2.Auth.Tests/RandomTests.cs
  7. 35
    0
      Luticate2.Auth/Utils/Business/Converters/LuConvertersAllocator.cs
  8. 15
    0
      Luticate2.Auth/Utils/Business/Converters/LuConvertersOptions.cs
  9. 26
    0
      Luticate2.Auth/Utils/Business/Converters/LuConvertersTypeConverter.cs
  10. 3
    2
      Luticate2.Auth/Utils/Business/Crud/LuEfCrudBusiness.cs
  11. 0
    15
      Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionConverterOptions.cs
  12. 6
    6
      Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionConverterVisitor.cs
  13. 3
    2
      Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionParamReplaceVisitor.cs
  14. 3
    2
      Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterIdentity.cs
  15. 86
    0
      Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterLists.cs
  16. 19
    22
      Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterPoco.cs
  17. 38
    0
      Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterUtils.cs
  18. 12
    20
      Luticate2.Auth/Utils/Business/ObjectConverterDescriptor/LuObjectConverterDescriptor.cs
  19. 3
    2
      Luticate2.Auth/Utils/Business/ObjectConverterDescriptor/LuObjectConverterDescriptorIdentity.cs
  20. 9
    0
      Luticate2.Auth/Utils/Interfaces/ILuConvertersAllocator.cs
  21. 9
    0
      Luticate2.Auth/Utils/Interfaces/ILuConvertersTypeConverter.cs
  22. 2
    1
      Luticate2.Auth/Utils/Interfaces/ILuObjectConverter.cs
  23. 3
    2
      Luticate2.Auth/Utils/Interfaces/ILuObjectConverterDescriptor.cs

+ 11
- 3
.idea/.idea.luticate2/.idea/contentModel.xml View File

@@ -40,21 +40,27 @@
40 40
         <e p="Luticate2.Auth.csproj" t="IncludeRecursive" />
41 41
         <e p="Utils" t="Include">
42 42
           <e p="Business" t="Include">
43
+            <e p="Converters" t="Include">
44
+              <e p="LuConvertersAllocator.cs" t="Include" />
45
+              <e p="LuConvertersOptions.cs" t="Include" />
46
+              <e p="LuConvertersTypeConverter.cs" t="Include" />
47
+            </e>
43 48
             <e p="Crud" t="Include">
44 49
               <e p="LuEfCrudBusiness.cs" t="Include" />
45 50
             </e>
46 51
             <e p="ExpressionConverter" t="Include">
47
-              <e p="LuExpressionConverterOptions.cs" t="Include" />
48 52
               <e p="LuExpressionConverterVisitor.cs" t="Include" />
49 53
               <e p="LuExpressionParamReplaceVisitor.cs" t="Include" />
50
-              <e p="LuObjectConverterIdentity.cs" t="Include" />
51 54
             </e>
52 55
             <e p="Fields" t="Include">
53 56
               <e p="LuFieldsExtensions.cs" t="Include" />
54 57
               <e p="LuPartialFieldsParser.cs" t="Include" />
55 58
             </e>
56 59
             <e p="ObjectConverter" t="Include">
60
+              <e p="LuObjectConverterIdentity.cs" t="Include" />
61
+              <e p="LuObjectConverterLists.cs" t="Include" />
57 62
               <e p="LuObjectConverterPoco.cs" t="Include" />
63
+              <e p="LuObjectConverterUtils.cs" t="Include" />
58 64
             </e>
59 65
             <e p="ObjectConverterDescriptor" t="Include">
60 66
               <e p="LuObjectConverterDescriptor.cs" t="Include" />
@@ -108,6 +114,8 @@
108 114
             <e p="LuResultException.cs" t="Include" />
109 115
           </e>
110 116
           <e p="Interfaces" t="Include">
117
+            <e p="ILuConvertersAllocator.cs" t="Include" />
118
+            <e p="ILuConvertersTypeConverter.cs" t="Include" />
111 119
             <e p="ILuCrud.cs" t="Include" />
112 120
             <e p="ILuObjectConverter.cs" t="Include" />
113 121
             <e p="ILuObjectConverterDescriptor.cs" t="Include" />
@@ -150,7 +158,7 @@
150 158
             <e p="LuFieldDboTests.cs" t="Include" />
151 159
           </e>
152 160
           <e p="ObjectConverter" t="Include">
153
-            <e p="ObjectConverter.cs" t="Include" />
161
+            <e p="ObjectConverterTests.cs" t="Include" />
154 162
             <e p="Objects.cs" t="Include" />
155 163
           </e>
156 164
           <e p="Pagination" t="Include">

+ 8
- 7
Luticate2.Auth.Tests/Business/ExpressionConverter/ExpressionConverterTests.cs View File

@@ -2,6 +2,7 @@ using System;
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5
+using Luticate2.Auth.Utils.Business.Converters;
5 6
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
6 7
 using Luticate2.Auth.Utils.Business.ObjectConverterDescriptor;
7 8
 using Luticate2.Auth.Utils.Interfaces;
@@ -29,16 +30,16 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
29 30
             return serviceProvider;
30 31
         }
31 32
 
32
-        protected LuExpressionConverterOptions GetConverterOptions()
33
+        protected LuConvertersOptions GetConverterOptions()
33 34
         {
34
-            var options = new LuExpressionConverterOptions
35
+            var options = new LuConvertersOptions
35 36
             {
36 37
                 Parameters = new Dictionary<ParameterExpression, Expression>(),
37
-                Types = new Dictionary<Type, Type>
38
+                TypeConverter = new LuConvertersTypeConverter(new Dictionary<Type, Type>
38 39
                 {
39 40
                     {typeof(TestDbo1), typeof(TestModel1)},
40 41
                     {typeof(TestDbo2), typeof(TestModel2)}
41
-                }
42
+                })
42 43
             };
43 44
             return options;
44 45
         }
@@ -102,7 +103,7 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
102 103
         public void TestVirtualProperty1()
103 104
         {
104 105
             Expression<Func<TestDbo2, string>> expDbo = (x => x.NameVirtual);
105
-            Expression<Func<TestModel2, string>> expModel = (Param_0 => Param_0.name + " " + Param_0.name);
106
+            Expression<Func<TestModel2, string>> expModel = (Param_0 => Param_0.name == null ? "[no data]" : Param_0.name + " " + Param_0.name);
106 107
             var converter = GetConverter();
107 108
             var result = converter.Visit(expDbo);
108 109
             Assert.Equal(expModel.ToString(), result?.ToString());
@@ -112,7 +113,7 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
112 113
         public void TestVirtualProperty2()
113 114
         {
114 115
             Expression<Func<TestDbo2, string>> expDbo = (x => x.Parent.NameVirtual);
115
-            Expression<Func<TestModel2, string>> expModel = (Param_0 => Param_0.parent.name + " " + Param_0.parent.name);
116
+            Expression<Func<TestModel2, string>> expModel = (Param_0 => Param_0.parent.name == null ? "[no data]" : Param_0.parent.name + " " + Param_0.parent.name);
116 117
             var converter = GetConverter();
117 118
             var result = converter.Visit(expDbo);
118 119
             Assert.Equal(expModel.ToString(), result?.ToString());
@@ -162,7 +163,7 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
162 163
         public void TestComplexExpression2()
163 164
         {
164 165
             Expression<Func<TestDbo2, int>> expDbo = (x => (x.NameVirtual + " " + x.Name).Length);
165
-            Expression<Func<TestModel2, int>> expModel = (Param_0 => (Param_0.name + " " + Param_0.name + " " + Param_0.name).Length);
166
+            Expression<Func<TestModel2, int>> expModel = (Param_0 => ((Param_0.name == null ? "[no data]" : (Param_0.name + " " + Param_0.name)) + " " + Param_0.name).Length);
166 167
             var converter = GetConverter();
167 168
             var result = converter.Visit(expDbo);
168 169
             Assert.Equal(expModel.ToString(), result?.ToString());

+ 8
- 8
Luticate2.Auth.Tests/Business/ExpressionConverter/Objects.cs View File

@@ -67,9 +67,9 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
67 67
     {
68 68
         public LuOcdTest1()
69 69
         {
70
-            AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
71
-            AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
72
-            AddMemberConverter(x => x.TestDbo2s, y => y.test_model2, PropertyType.Object);
70
+            AddMemberConverter(x => x.Id, y => y.id);
71
+            AddMemberConverter(x => x.Name, y => y.name);
72
+            AddMemberConverter(x => x.TestDbo2s, y => y.test_model2);
73 73
             AddStaticMethodConverter(
74 74
                 (Expression<Func<TestDbo1, string>>)(x => x.ToString()),
75 75
                 (Expression<Func<TestModel1, string>>)(x => x.id + ": " + x.name)
@@ -81,11 +81,11 @@ namespace Luticate2.Auth.Tests.Business.ExpressionConverter
81 81
     {
82 82
         public LuOcdTest2()
83 83
         {
84
-            AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
85
-            AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
86
-            AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name, PropertyType.Value);
87
-            AddMemberConverter(x => x.TestDbo1, y => y.test_model1, PropertyType.Object);
88
-            AddMemberConverter(x => x.Parent, y => y.parent, PropertyType.Object);
84
+            AddMemberConverter(x => x.Id, y => y.id);
85
+            AddMemberConverter(x => x.Name, y => y.name);
86
+            AddMemberConverter(x => x.NameVirtual, y => y.name == null ? "[no data]" : (y.name + " " + y.name));
87
+            AddMemberConverter(x => x.TestDbo1, y => y.test_model1);
88
+            AddMemberConverter(x => x.Parent, y => y.parent);
89 89
         }
90 90
     }
91 91
 }

+ 45
- 10
Luticate2.Auth.Tests/Business/ObjectConverter/ObjectConverterTests.cs View File

@@ -1,7 +1,10 @@
1 1
 using System;
2
+using System.Collections;
2 3
 using System.Collections.Generic;
4
+using System.Collections.ObjectModel;
3 5
 using System.Linq;
4 6
 using System.Linq.Expressions;
7
+using Luticate2.Auth.Utils.Business.Converters;
5 8
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
6 9
 using Luticate2.Auth.Utils.Business.Fields;
7 10
 using Luticate2.Auth.Utils.Business.ObjectConverter;
@@ -23,14 +26,38 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
23 26
             var typeILuObjectConverterDescriptorEnumerable =
24 27
                 typeILuObjectConverterDescriptor.MakeGenericType(typeof(Enumerable), typeof(Enumerable));
25 28
 
29
+            var typeILuObjectConverter = typeof(ILuObjectConverter<,>);
30
+            var listTypes = new []
31
+            {
32
+                typeof(IEnumerable<>),
33
+                typeof(ICollection<>),
34
+                typeof(Collection<>),
35
+                typeof(IList<>),
36
+                typeof(List<>)
37
+            };
38
+            var listImplemType = new Dictionary<Type, Type>
39
+            {
40
+                {typeof(IEnumerable<>), typeof(LuObjectConverterList)},
41
+                {typeof(ICollection<>), typeof(LuObjectConverterCollection)},
42
+                {typeof(Collection<>), typeof(LuObjectConverterCollection)},
43
+                {typeof(IList<>), typeof(LuObjectConverterList)},
44
+                {typeof(List<>), typeof(LuObjectConverterList)}
45
+            };
46
+
26 47
             var services = new ServiceCollection();
27 48
             services.AddSingleton<ILuObjectConverterDescriptorIdentity, LuObjectConverterDescriptorIdentity>();
28 49
             services.AddSingleton(typeILuObjectConverterDescriptorEnumerable, typeof(LuObjectConverterDescriptorEnumerable));
29 50
             services.AddSingleton<ILuObjectConverterDescriptor<TestDbo1, TestModel1>, LuOcdTest1>();
30 51
             services.AddSingleton<ILuObjectConverterDescriptor<TestDbo2, TestModel2>, LuOcdTest2>();
31 52
 
32
-
33 53
             services.AddSingleton<ILuObjectConverterIdentity, LuObjectConverterIdentity>();
54
+            foreach (var typeFrom in listTypes)
55
+            {
56
+                foreach (var typeTo in listTypes)
57
+                {
58
+                    services.AddSingleton(typeILuObjectConverter.MakeGenericType(typeFrom, typeTo), listImplemType[typeTo]);
59
+                }
60
+            }
34 61
             services.AddSingleton<ILuObjectConverter<TestModel1, TestDbo1>, LuObjectConverterPoco<TestModel1, TestDbo1>>();
35 62
             services.AddSingleton<ILuObjectConverter<TestModel2, TestDbo2>, LuObjectConverterPoco<TestModel2, TestDbo2>>();
36 63
 
@@ -38,20 +65,19 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
38 65
             return serviceProvider;
39 66
         }
40 67
 
41
-        protected LuExpressionConverterOptions GetConverterOptions()
68
+        protected LuConvertersOptions GetConverterOptions()
42 69
         {
43
-            var options = new LuExpressionConverterOptions
70
+            var options = new LuConvertersOptions
44 71
             {
45 72
                 Parameters = new Dictionary<ParameterExpression, Expression>(),
46
-                Types = new Dictionary<Type, Type>
73
+                TypeConverter = new LuConvertersTypeConverter(new Dictionary<Type, Type>
47 74
                 {
48 75
                     {typeof(TestDbo1), typeof(TestModel1)},
49
-                    {typeof(TestDbo2), typeof(TestModel2)}
50
-                },
51
-                Allocator = type =>
52
-                {
53
-                    return Activator.CreateInstance(type);
54
-                }
76
+                    {typeof(TestDbo2), typeof(TestModel2)},
77
+                    {typeof(TestModel1), typeof(TestDbo1)},
78
+                    {typeof(TestModel2), typeof(TestDbo2)}
79
+                }),
80
+                Allocator = new LuConvertersAllocator()
55 81
             };
56 82
             return options;
57 83
         }
@@ -83,6 +109,15 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
83 109
             Assert.NotNull(dbo);
84 110
             Assert.Equal(model.id, dbo.Id);
85 111
             Assert.Equal(model.name, dbo.Name);
112
+            Assert.Equal(model.test_model2.Count, dbo.TestDbo2s.Count);
113
+            foreach (var e in model.test_model2.Zip(dbo.TestDbo2s, (model2, dbo2) => new {Model = model2, Dbo = dbo2}))
114
+            {
115
+                Assert.Equal(e.Model.id, e.Dbo.Id);
116
+                Assert.Equal(e.Model.name, e.Dbo.Name);
117
+                Assert.Equal(e.Model.name + " " + e.Model.name, e.Dbo.NameVirtual);
118
+                Assert.Equal(null, e.Dbo.Parent);
119
+                Assert.Equal(null, e.Dbo.TestDbo1);
120
+            }
86 121
         }
87 122
     }
88 123
 }

+ 11
- 10
Luticate2.Auth.Tests/Business/ObjectConverter/Objects.cs View File

@@ -18,7 +18,7 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
18 18
 
19 19
         public string Name { get; set; }
20 20
 
21
-//        public IList<TestDbo2> TestDbo2s { get; set; } // TODO
21
+        public IList<TestDbo2> TestDbo2s { get; set; }
22 22
 
23 23
         public string ToString()
24 24
         {
@@ -38,7 +38,7 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
38 38
 
39 39
         public TestDbo2 Parent { get; set; }
40 40
 
41
-        public TestModel1 Unused { get; set; }
41
+        public TestDbo1 Unused { get; set; }
42 42
     }
43 43
 
44 44
     public class TestModel1
@@ -67,9 +67,9 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
67 67
     {
68 68
         public LuOcdTest1()
69 69
         {
70
-            AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
71
-            AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
72
-//            AddMemberConverter(x => x.TestDbo2s, y => y.test_model2, PropertyType.Object); // TODO
70
+            AddMemberConverter(x => x.Id, y => y.id);
71
+            AddMemberConverter(x => x.Name, y => y.name);
72
+            AddMemberConverter(x => x.TestDbo2s, y => y.test_model2);
73 73
             AddStaticMethodConverter(
74 74
                 (Expression<Func<TestDbo1, string>>)(x => x.ToString()),
75 75
                 (Expression<Func<TestModel1, string>>)(x => x.id + ": " + x.name)
@@ -81,11 +81,12 @@ namespace Luticate2.Auth.Tests.Business.ObjectConverter
81 81
     {
82 82
         public LuOcdTest2()
83 83
         {
84
-            AddMemberConverter(x => x.Id, y => y.id, PropertyType.Value);
85
-            AddMemberConverter(x => x.Name, y => y.name, PropertyType.Value);
86
-            AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name, PropertyType.Value);
87
-            AddMemberConverter(x => x.TestDbo1, y => y.test_model1, PropertyType.Object);
88
-            AddMemberConverter(x => x.Parent, y => y.parent, PropertyType.Object);
84
+            AddMemberConverter(x => x.Id, y => y.id);
85
+            AddMemberConverter(x => x.Name, y => y.name);
86
+            AddMemberConverter(x => x.NameVirtual, y => y.name + " " + y.name);
87
+            AddMemberConverter(x => x.TestDbo1, y => y.test_model1);
88
+            AddMemberConverter(x => x.Parent, y => y.parent);
89
+            AddMemberConverter((LambdaExpression) (Expression<Func<TestDbo2, TestDbo1>>) (x => x.Unused), (Expression<Func<TestModel2, TestModel1>>) (y => null));
89 90
         }
90 91
     }
91 92
 }

+ 12
- 9
Luticate2.Auth.Tests/RandomTests.cs View File

@@ -1,4 +1,7 @@
1
-namespace Luticate2.Auth.Tests
1
+using Luticate2.Auth.Utils.Business.ObjectConverter;
2
+using Xunit;
3
+
4
+namespace Luticate2.Auth.Tests
2 5
 {
3 6
     public class RandomTests
4 7
     {
@@ -40,14 +43,14 @@
40 43
 //            services.TryAddSingleton<ILuExpressionConverter<TTypeFrom>, TTypeImpl>();
41 44
 //        }
42 45
 
43
-//        [Fact]
44
-//        public void Test()
45
-//        {
46
-////            var parentScopeVar = new TestDbo1();
47
-////            Expression<Func<TestDbo2, Guid>> expDbo = (x => parentScopeVar.Id);
48
-////            var type = typeof(ILuObjectConverterDescriptor<,>);
49
-////            var gtype = type.MakeGenericType(typeof(int), typeof(Enumerable));
50
-//        }
46
+        [Fact]
47
+        public void Test()
48
+        {
49
+//            var parentScopeVar = new TestDbo1();
50
+//            Expression<Func<TestDbo2, Guid>> expDbo = (x => parentScopeVar.Id);
51
+//            var type = typeof(ILuObjectConverterDescriptor<,>);
52
+//            var gtype = type.MakeGenericType(typeof(int), typeof(Enumerable));
53
+        }
51 54
 
52 55
     }
53 56
 }

+ 35
- 0
Luticate2.Auth/Utils/Business/Converters/LuConvertersAllocator.cs View File

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.Collections.ObjectModel;
5
+using Luticate2.Auth.Utils.Interfaces;
6
+
7
+namespace Luticate2.Auth.Utils.Business.Converters
8
+{
9
+    public class LuConvertersAllocator : ILuConvertersAllocator
10
+    {
11
+        protected static IDictionary<Type, Type> listTypes = new Dictionary<Type, Type>
12
+        {
13
+            {typeof(IEnumerable<>), typeof(List<>)},
14
+            {typeof(ICollection<>), typeof(Collection<>)},
15
+            {typeof(Collection<>), typeof(Collection<>)},
16
+            {typeof(IList<>), typeof(List<>)},
17
+            {typeof(List<>), typeof(List<>)}
18
+        };
19
+
20
+        public object GetInstance(Type type)
21
+        {
22
+            if (type.IsGenericType)
23
+            {
24
+                var gtype = type.GetGenericTypeDefinition();
25
+
26
+                if (listTypes.ContainsKey(gtype))
27
+                {
28
+                    var glistType = listTypes[gtype].MakeGenericType(type.GenericTypeArguments[0]);
29
+                    return Activator.CreateInstance(glistType);
30
+                }
31
+            }
32
+            return Activator.CreateInstance(type);
33
+        }
34
+    }
35
+}

+ 15
- 0
Luticate2.Auth/Utils/Business/Converters/LuConvertersOptions.cs View File

@@ -0,0 +1,15 @@
1
+using System.Collections.Generic;
2
+using System.Linq.Expressions;
3
+using Luticate2.Auth.Utils.Interfaces;
4
+
5
+namespace Luticate2.Auth.Utils.Business.Converters
6
+{
7
+    public class LuConvertersOptions
8
+    {
9
+        public IDictionary<ParameterExpression, Expression> Parameters { get; set; }
10
+
11
+        public ILuConvertersTypeConverter TypeConverter { get; set; }
12
+
13
+        public ILuConvertersAllocator Allocator { get; set; }
14
+    }
15
+}

+ 26
- 0
Luticate2.Auth/Utils/Business/Converters/LuConvertersTypeConverter.cs View File

@@ -0,0 +1,26 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using Luticate2.Auth.Utils.Interfaces;
4
+
5
+namespace Luticate2.Auth.Utils.Business.Converters
6
+{
7
+    public class LuConvertersTypeConverter : ILuConvertersTypeConverter
8
+    {
9
+        protected IDictionary<Type, Type> Types { get; set; }
10
+
11
+        public LuConvertersTypeConverter(IDictionary<Type, Type> types)
12
+        {
13
+            Types = types;
14
+        }
15
+
16
+        public Type ConvertType(Type typeFrom)
17
+        {
18
+            if (Types.ContainsKey(typeFrom))
19
+            {
20
+                return Types[typeFrom];
21
+            }
22
+
23
+            return typeFrom;
24
+        }
25
+    }
26
+}

+ 3
- 2
Luticate2.Auth/Utils/Business/Crud/LuEfCrudBusiness.cs View File

@@ -2,6 +2,7 @@
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5
+using Luticate2.Auth.Utils.Business.Converters;
5 6
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
6 7
 using Luticate2.Auth.Utils.Dbo;
7 8
 using Luticate2.Auth.Utils.Dbo.Fields;
@@ -78,10 +79,10 @@ namespace Luticate2.Auth.Utils.Business.Crud
78 79
         {
79 80
             var lamdbaDbo = (Expression<Func<TDbo, bool>>) filter.Expression;
80 81
 
81
-            var options = new LuExpressionConverterOptions
82
+            var options = new LuConvertersOptions
82 83
             {
83 84
                 Parameters = new Dictionary<ParameterExpression, Expression>(), // TODO
84
-                Types = null // TODO
85
+                TypeConverter = null // TODO
85 86
             };
86 87
             var converter = new LuExpressionConverterVisitor(options, ServiceProvider);
87 88
             var lamdbaModel = converter.Visit(lamdbaDbo) as Expression<Func<TModel, bool>>;// TODO Handle errors

+ 0
- 15
Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionConverterOptions.cs View File

@@ -1,15 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq.Expressions;
4
-
5
-namespace Luticate2.Auth.Utils.Business.ExpressionConverter
6
-{
7
-    public class LuExpressionConverterOptions
8
-    {
9
-        public IDictionary<ParameterExpression, Expression> Parameters { get; set; }
10
-
11
-        public IDictionary<Type, Type> Types { get; set; }
12
-
13
-        public Func<Type, object> Allocator { get; set; }
14
-    }
15
-}

+ 6
- 6
Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionConverterVisitor.cs View File

@@ -2,6 +2,7 @@
2 2
 using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5
+using Luticate2.Auth.Utils.Business.Converters;
5 6
 using Luticate2.Auth.Utils.Business.Utils;
6 7
 using Luticate2.Auth.Utils.Dbo;
7 8
 using Luticate2.Auth.Utils.Dbo.Result;
@@ -12,11 +13,11 @@ namespace Luticate2.Auth.Utils.Business.ExpressionConverter
12 13
 {
13 14
     public class LuExpressionConverterVisitor : ExpressionVisitor
14 15
     {
15
-        public LuExpressionConverterOptions Options { get; }
16
+        public LuConvertersOptions Options { get; }
16 17
 
17 18
         protected IServiceProvider ServiceProvider { get; }
18 19
 
19
-        public LuExpressionConverterVisitor(LuExpressionConverterOptions options, IServiceProvider serviceProvider)
20
+        public LuExpressionConverterVisitor(LuConvertersOptions options, IServiceProvider serviceProvider)
20 21
         {
21 22
             Options = options;
22 23
             ServiceProvider = serviceProvider;
@@ -163,7 +164,7 @@ namespace Luticate2.Auth.Utils.Business.ExpressionConverter
163 164
             else if (currentExp is MemberExpression memberExpression)
164 165
             {
165 166
                 var typeFrom = memberExpression.Member.DeclaringType;
166
-                var typeTo = Options.Types.ContainsKey(typeFrom) ? Options.Types[typeFrom] : typeFrom;
167
+                var typeTo = Options.TypeConverter.ConvertType(typeFrom);
167 168
 
168 169
                 var convertResult = ConvertMemberExpression(memberExpression, null, typeTo);
169 170
                 if (!convertResult)
@@ -176,7 +177,7 @@ namespace Luticate2.Auth.Utils.Business.ExpressionConverter
176 177
             else if (currentExp is MethodCallExpression methodCallExpression)
177 178
             {
178 179
                 var typeFrom = methodCallExpression.Method.DeclaringType;
179
-                var typeTo = Options.Types.ContainsKey(typeFrom) ? Options.Types[typeFrom] : typeFrom;
180
+                var typeTo = Options.TypeConverter.ConvertType(typeFrom);
180 181
 
181 182
                 var convertResult = ConvertMethodCallExpression(methodCallExpression, null, typeTo);
182 183
                 if (!convertResult)
@@ -261,8 +262,7 @@ namespace Luticate2.Auth.Utils.Business.ExpressionConverter
261 262
             var convertedParams = new List<ParameterExpression>();
262 263
             foreach (var parameter in node.Parameters)
263 264
             {
264
-                // TODO check Options.Types[parameter.Type] access
265
-                var convertedParam = Expression.Parameter(Options.Types[parameter.Type]);
265
+                var convertedParam = Expression.Parameter(Options.TypeConverter.ConvertType(parameter.Type));
266 266
                 Options.Parameters.Add(parameter, convertedParam);
267 267
                 convertedParams.Add(convertedParam);
268 268
             }

+ 3
- 2
Luticate2.Auth/Utils/Business/ExpressionConverter/LuExpressionParamReplaceVisitor.cs View File

@@ -1,4 +1,5 @@
1 1
 using System.Linq.Expressions;
2
+using Luticate2.Auth.Utils.Business.Converters;
2 3
 using Luticate2.Auth.Utils.Dbo;
3 4
 using Luticate2.Auth.Utils.Dbo.Result;
4 5
 using Luticate2.Auth.Utils.Exceptions;
@@ -7,9 +8,9 @@ namespace Luticate2.Auth.Utils.Business.ExpressionConverter
7 8
 {
8 9
     public class LuExpressionParamReplaceVisitor : ExpressionVisitor
9 10
     {
10
-        public LuExpressionConverterOptions Options { get; }
11
+        public LuConvertersOptions Options { get; }
11 12
 
12
-        public LuExpressionParamReplaceVisitor(LuExpressionConverterOptions options)
13
+        public LuExpressionParamReplaceVisitor(LuConvertersOptions options)
13 14
         {
14 15
             Options = options;
15 16
         }

Luticate2.Auth/Utils/Business/ExpressionConverter/LuObjectConverterIdentity.cs → Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterIdentity.cs View File

@@ -1,12 +1,13 @@
1
+using Luticate2.Auth.Utils.Business.Converters;
1 2
 using Luticate2.Auth.Utils.Dbo.Fields;
2 3
 using Luticate2.Auth.Utils.Dbo.Result;
3 4
 using Luticate2.Auth.Utils.Interfaces;
4 5
 
5
-namespace Luticate2.Auth.Utils.Business.ExpressionConverter
6
+namespace Luticate2.Auth.Utils.Business.ObjectConverter
6 7
 {
7 8
     public class LuObjectConverterIdentity : ILuObjectConverterIdentity
8 9
     {
9
-        public LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuExpressionConverterOptions options)
10
+        public LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuConvertersOptions options)
10 11
         {
11 12
             return LuResult<object>.Ok(srcObj);
12 13
         }

+ 86
- 0
Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterLists.cs View File

@@ -0,0 +1,86 @@
1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.Collections.ObjectModel;
5
+using Luticate2.Auth.Utils.Business.Converters;
6
+using Luticate2.Auth.Utils.Dbo;
7
+using Luticate2.Auth.Utils.Dbo.Fields;
8
+using Luticate2.Auth.Utils.Dbo.Result;
9
+using Luticate2.Auth.Utils.Interfaces;
10
+
11
+namespace Luticate2.Auth.Utils.Business.ObjectConverter
12
+{
13
+    public abstract class LuObjectConverterLists : ILuObjectConverter
14
+    {
15
+        protected IServiceProvider ServiceProvider { get; }
16
+
17
+        public LuObjectConverterLists(IServiceProvider serviceProvider)
18
+        {
19
+            ServiceProvider = serviceProvider;
20
+        }
21
+
22
+        protected abstract Type GetListType();
23
+
24
+        public LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuConvertersOptions options)
25
+        {
26
+            if (srcObj is IEnumerable enumerable)
27
+            {
28
+                var listType = GetListType();
29
+                var listTypeTo = options.TypeConverter.ConvertType(srcObj.GetType().GetGenericArguments()[0]);
30
+                var glistType = listType.MakeGenericType(listTypeTo);
31
+                var collection = options.Allocator.GetInstance(glistType);
32
+                foreach (var obj in enumerable)
33
+                {
34
+                    object convertedObj = null;
35
+                    if (obj != null)
36
+                    {
37
+                        var typeFrom = obj.GetType();
38
+                        var typeTo = options.TypeConverter.ConvertType(typeFrom);
39
+                        // TODO Handle converter == null
40
+                        var converter = LuObjectConverterUtils.GetObjectConverter(ServiceProvider, typeFrom, typeTo);
41
+                        var convertResult = converter.Convert(obj, fields, options);
42
+                        if (!convertResult)
43
+                        {
44
+                            return convertResult;
45
+                        }
46
+
47
+                        convertedObj = convertResult.Data;
48
+                    }
49
+
50
+                    var methodInfo = collection.GetType().GetMethod(nameof(ICollection<object>.Add));
51
+                    methodInfo.Invoke(collection, new []{convertedObj});
52
+                }
53
+
54
+                return LuResult<object>.Ok(collection);
55
+            }
56
+            else
57
+            {
58
+                return LuResult<object>.Error(LuStatus.InputError.ToInt(), $"Could not convert {nameof(srcObj)} to {nameof(IEnumerable)}");
59
+            }
60
+        }
61
+    }
62
+
63
+    public class LuObjectConverterList : LuObjectConverterLists
64
+    {
65
+        public LuObjectConverterList(IServiceProvider serviceProvider) : base(serviceProvider)
66
+        {
67
+        }
68
+
69
+        protected override Type GetListType()
70
+        {
71
+            return typeof(List<>);
72
+        }
73
+    }
74
+
75
+    public class LuObjectConverterCollection : LuObjectConverterLists
76
+    {
77
+        public LuObjectConverterCollection(IServiceProvider serviceProvider) : base(serviceProvider)
78
+        {
79
+        }
80
+
81
+        protected override Type GetListType()
82
+        {
83
+            return typeof(Collection<>);
84
+        }
85
+    }
86
+}

+ 19
- 22
Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterPoco.cs View File

@@ -1,5 +1,5 @@
1 1
 using System;
2
-using Luticate2.Auth.Utils.Business.ExpressionConverter;
2
+using Luticate2.Auth.Utils.Business.Converters;
3 3
 using Luticate2.Auth.Utils.Business.Utils;
4 4
 using Luticate2.Auth.Utils.Dbo.Fields;
5 5
 using Luticate2.Auth.Utils.Dbo.Result;
@@ -17,19 +17,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverter
17 17
             ServiceProvider = serviceProvider;
18 18
         }
19 19
 
20
-        protected ILuObjectConverter GetObjectConverter(Type typeFrom, Type typeTo)
21
-        {
22
-            var type = typeof(ILuObjectConverter<,>);
23
-            var gtype = type.MakeGenericType(typeFrom, typeTo);
24
-            var converter = (ILuObjectConverter) ServiceProvider.GetService(gtype);
25
-            if (converter == null && typeFrom == typeTo)
26
-            {
27
-                converter = (ILuObjectConverter) ServiceProvider.GetService(typeof(ILuObjectConverterIdentity));
28
-            }
29
-            return converter;
30
-        }
31
-
32
-        public LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuExpressionConverterOptions options)
20
+        public LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuConvertersOptions options)
33 21
         {
34 22
             // TODO Check if this is correct
35 23
             if (srcObj == null)
@@ -39,23 +27,32 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverter
39 27
             // TODO Handle descriptor == null
40 28
             var descriptor = ServiceProvider.GetService<ILuObjectConverterDescriptor<TTypeTo, TTypeFrom>>();
41 29
             var typeTo = typeof(TTypeTo);
42
-            var dstObj = options.Allocator(typeTo);
30
+            var dstObj = options.Allocator.GetInstance(typeTo);
43 31
 
44 32
             foreach (var memberInfo in typeTo.GetProperties())
45 33
             {
46 34
                 // TODO check if field is included in fields
47
-                // TODO Handle valueExpression == null
35
+                // TODO Handle srcPropExpression == null
48 36
                 var srcPropExpression = descriptor.GetMemberValueExpression(memberInfo, options);
49 37
                 var srcPropDelegate = srcPropExpression.Compile();
50 38
                 var srcProp = srcPropDelegate.DynamicInvoke(srcObj);
51
-
52
-                var objectConverter = GetObjectConverter(srcProp.GetType(), memberInfo.GetUnderlyingType());
53
-                var dstProp = objectConverter.Convert(srcProp, fields, options);
54
-                if (!dstProp)
39
+                object dstProp = null;
40
+                if (srcProp != null)
55 41
                 {
56
-                    return dstProp;
42
+                    var srcType = srcProp.GetType();
43
+
44
+                    // TODO Handle objectConverter == null
45
+                    var objectConverter = LuObjectConverterUtils.GetObjectConverter(ServiceProvider, srcType, memberInfo.GetUnderlyingType());
46
+                    var dstPropResult = objectConverter.Convert(srcProp, fields, options);
47
+                    if (!dstPropResult)
48
+                    {
49
+                        return dstPropResult;
50
+                    }
51
+
52
+                    dstProp = dstPropResult.Data;
57 53
                 }
58
-                var result = LuExpressionUtils.SetValueFromMember(memberInfo, dstObj, dstProp.Data);
54
+
55
+                var result = LuExpressionUtils.SetValueFromMember(memberInfo, dstObj, dstProp);
59 56
                 if (!result)
60 57
                 {
61 58
                     return result.To<object>();

+ 38
- 0
Luticate2.Auth/Utils/Business/ObjectConverter/LuObjectConverterUtils.cs View File

@@ -0,0 +1,38 @@
1
+using System;
2
+using Luticate2.Auth.Utils.Interfaces;
3
+
4
+namespace Luticate2.Auth.Utils.Business.ObjectConverter
5
+{
6
+    public static class LuObjectConverterUtils
7
+    {
8
+        public static ILuObjectConverter GetObjectConverter(IServiceProvider serviceProvider, Type typeFrom, Type typeTo)
9
+        {
10
+            var type = typeof(ILuObjectConverter<,>);
11
+            var gtype = type.MakeGenericType(typeFrom, typeTo);
12
+            var converter = (ILuObjectConverter) serviceProvider.GetService(gtype);
13
+
14
+            if (converter == null)
15
+            {
16
+                var baseTypeFrom = typeFrom;
17
+                if (typeFrom.IsGenericType)
18
+                {
19
+                    baseTypeFrom = typeFrom.GetGenericTypeDefinition();
20
+                }
21
+                var baseTypeTo = typeTo;
22
+                if (typeTo.IsGenericType)
23
+                {
24
+                    baseTypeTo = typeTo.GetGenericTypeDefinition();
25
+                }
26
+                gtype = type.MakeGenericType(baseTypeFrom, baseTypeTo);
27
+                converter = (ILuObjectConverter) serviceProvider.GetService(gtype);
28
+            }
29
+
30
+            if (converter == null && typeFrom == typeTo)
31
+            {
32
+                converter = (ILuObjectConverter) serviceProvider.GetService(typeof(ILuObjectConverterIdentity));
33
+            }
34
+
35
+            return converter;
36
+        }
37
+    }
38
+}

+ 12
- 20
Luticate2.Auth/Utils/Business/ObjectConverterDescriptor/LuObjectConverterDescriptor.cs View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
3 3
 using System.Linq;
4 4
 using System.Linq.Expressions;
5 5
 using System.Reflection;
6
+using Luticate2.Auth.Utils.Business.Converters;
6 7
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
7 8
 using Luticate2.Auth.Utils.Business.Utils;
8 9
 using Luticate2.Auth.Utils.Interfaces;
@@ -11,17 +12,9 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
11 12
 {
12 13
     public class LuObjectConverterDescriptor : ILuObjectConverterDescriptor
13 14
     {
14
-        protected enum PropertyType
15
-        {
16
-            Value,
17
-            Object
18
-        }
19
-
20 15
         protected class LuObjectConverterDescriptorMemberInfo
21 16
         {
22 17
             public LambdaExpression ValueExpression { get; set; }
23
-
24
-            public PropertyType PropertyType { get; set; }
25 18
         }
26 19
 
27 20
         protected class LuObjectConverterDescriptorMethodInfo
@@ -29,7 +22,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
29 22
             public LambdaExpression ValueExpression { get; set; }
30 23
         }
31 24
 
32
-        protected delegate LuObjectConverterDescriptorMethodInfo DynamicMethodConverter(MethodInfo methodInfo, IDictionary<Type, Type> types);
25
+        protected delegate LuObjectConverterDescriptorMethodInfo DynamicMethodConverter(MethodInfo methodInfo, ILuConvertersTypeConverter typeConverter);
33 26
 
34 27
         private IDictionary<MemberInfo, LuObjectConverterDescriptorMemberInfo> StaticMemberConverters { get; } = new Dictionary<MemberInfo, LuObjectConverterDescriptorMemberInfo>();
35 28
 
@@ -37,14 +30,13 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
37 30
 
38 31
         private IDictionary<MethodInfo, DynamicMethodConverter> DynamicMethodConverters { get; } = new Dictionary<MethodInfo, DynamicMethodConverter>();
39 32
 
40
-        protected void AddMemberConverter(LambdaExpression memberFrom, LambdaExpression valueExpression, PropertyType propertyType)
33
+        protected void AddMemberConverter(LambdaExpression memberFrom, LambdaExpression valueExpression)
41 34
         {
42 35
             // TODO: check memberInfo != null
43 36
             var memberInfo = LuExpressionUtils.GetSingleMemberFromExpression(memberFrom);
44 37
             StaticMemberConverters.Add(memberInfo, new LuObjectConverterDescriptorMemberInfo
45 38
             {
46
-                ValueExpression = LuExpressionUtils.GetFromConvert(valueExpression),
47
-                PropertyType = propertyType
39
+                ValueExpression = LuExpressionUtils.GetFromConvert(valueExpression)
48 40
             });
49 41
         }
50 42
 
@@ -69,10 +61,10 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
69 61
         protected void AddDynamicMethodConverterTemplate(LambdaExpression methodFrom)
70 62
         {
71 63
             AddDynamicMethodConverter(methodFrom,
72
-                (info, types) =>
64
+                (info, converter) =>
73 65
                 {
74 66
                     var genericMethodInfo = info.GetGenericMethodDefinition();
75
-                    var templateMethodInfo = genericMethodInfo.MakeGenericMethod(info.GetGenericArguments().Select(x => types[x]).ToArray());
67
+                    var templateMethodInfo = genericMethodInfo.MakeGenericMethod(info.GetGenericArguments().Select(converter.ConvertType).ToArray());
76 68
 
77 69
                     var lambdaParams = new List<ParameterExpression>
78 70
                     {
@@ -92,7 +84,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
92 84
             );
93 85
         }
94 86
 
95
-        public LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuExpressionConverterOptions options)
87
+        public LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuConvertersOptions options)
96 88
         {
97 89
             if (StaticMemberConverters.ContainsKey(memberInfo))
98 90
             {
@@ -102,7 +94,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
102 94
             return null;
103 95
         }
104 96
 
105
-        public LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuExpressionConverterOptions options)
97
+        public LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuConvertersOptions options)
106 98
         {
107 99
             if (StaticMethodConverters.ContainsKey(methodInfo))
108 100
             {
@@ -112,7 +104,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
112 104
             var genericMethodInfo = methodInfo.GetGenericMethodDefinition();
113 105
             if (DynamicMethodConverters.ContainsKey(genericMethodInfo))
114 106
             {
115
-                var result = DynamicMethodConverters[genericMethodInfo](methodInfo, options.Types);
107
+                var result = DynamicMethodConverters[genericMethodInfo](methodInfo, options.TypeConverter);
116 108
                 if (result != null)
117 109
                 {
118 110
                     return result.ValueExpression;
@@ -126,14 +118,14 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
126 118
     public class LuObjectConverterDescriptor<TTypeFrom, TTypeTo> : LuObjectConverterDescriptor, ILuObjectConverterDescriptor<TTypeFrom, TTypeTo>
127 119
     {
128 120
         protected void AddMemberConverter(Expression<Func<TTypeFrom, object>> memberFrom,
129
-            Expression<Func<TTypeTo, object>> valueExpression, PropertyType propertyType)
121
+            Expression<Func<TTypeTo, object>> valueExpression)
130 122
         {
131
-            AddMemberConverter((LambdaExpression) memberFrom, valueExpression, propertyType);
123
+            AddMemberConverter((LambdaExpression) memberFrom, valueExpression);
132 124
         }
133 125
 
134 126
         protected void AddNullMemberConverter(Expression<Func<TTypeFrom, object>> memberFrom)
135 127
         {
136
-            AddMemberConverter(memberFrom, to => default(TTypeTo), PropertyType.Value);
128
+            AddMemberConverter(memberFrom, to => null);
137 129
         }
138 130
     }
139 131
 }

+ 3
- 2
Luticate2.Auth/Utils/Business/ObjectConverterDescriptor/LuObjectConverterDescriptorIdentity.cs View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
2 2
 using System.Linq;
3 3
 using System.Linq.Expressions;
4 4
 using System.Reflection;
5
+using Luticate2.Auth.Utils.Business.Converters;
5 6
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
6 7
 using Luticate2.Auth.Utils.Interfaces;
7 8
 
@@ -9,7 +10,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
9 10
 {
10 11
     public class LuObjectConverterDescriptorIdentity : ILuObjectConverterDescriptorIdentity
11 12
     {
12
-        public LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuExpressionConverterOptions options)
13
+        public LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuConvertersOptions options)
13 14
         {
14 15
             var isStatic = false;
15 16
             if (memberInfo is FieldInfo fieldInfo)
@@ -26,7 +27,7 @@ namespace Luticate2.Auth.Utils.Business.ObjectConverterDescriptor
26 27
             return lambda;
27 28
         }
28 29
 
29
-        public LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuExpressionConverterOptions options)
30
+        public LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuConvertersOptions options)
30 31
         {
31 32
             var lambdaParams = new List<ParameterExpression>
32 33
             {

+ 9
- 0
Luticate2.Auth/Utils/Interfaces/ILuConvertersAllocator.cs View File

@@ -0,0 +1,9 @@
1
+using System;
2
+
3
+namespace Luticate2.Auth.Utils.Interfaces
4
+{
5
+    public interface ILuConvertersAllocator
6
+    {
7
+        object GetInstance(Type type);
8
+    }
9
+}

+ 9
- 0
Luticate2.Auth/Utils/Interfaces/ILuConvertersTypeConverter.cs View File

@@ -0,0 +1,9 @@
1
+using System;
2
+
3
+namespace Luticate2.Auth.Utils.Interfaces
4
+{
5
+    public interface ILuConvertersTypeConverter
6
+    {
7
+        Type ConvertType(Type typeFrom);
8
+    }
9
+}

+ 2
- 1
Luticate2.Auth/Utils/Interfaces/ILuObjectConverter.cs View File

@@ -1,3 +1,4 @@
1
+using Luticate2.Auth.Utils.Business.Converters;
1 2
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
2 3
 using Luticate2.Auth.Utils.Dbo.Fields;
3 4
 using Luticate2.Auth.Utils.Dbo.Result;
@@ -6,7 +7,7 @@ namespace Luticate2.Auth.Utils.Interfaces
6 7
 {
7 8
     public interface ILuObjectConverter
8 9
     {
9
-        LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuExpressionConverterOptions options);
10
+        LuResult<object> Convert(object srcObj, LuPartialFieldsDbo fields, LuConvertersOptions options);
10 11
     }
11 12
 
12 13
     public interface ILuObjectConverter<TTypeFrom, TTypeTo> : ILuObjectConverter

+ 3
- 2
Luticate2.Auth/Utils/Interfaces/ILuObjectConverterDescriptor.cs View File

@@ -1,14 +1,15 @@
1 1
 using System.Linq.Expressions;
2 2
 using System.Reflection;
3
+using Luticate2.Auth.Utils.Business.Converters;
3 4
 using Luticate2.Auth.Utils.Business.ExpressionConverter;
4 5
 
5 6
 namespace Luticate2.Auth.Utils.Interfaces
6 7
 {
7 8
     public interface ILuObjectConverterDescriptor
8 9
     {
9
-        LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuExpressionConverterOptions options);
10
+        LambdaExpression GetMemberValueExpression(MemberInfo memberInfo, LuConvertersOptions options);
10 11
 
11
-        LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuExpressionConverterOptions options);
12
+        LambdaExpression GetMethodValueExpression(MethodInfo methodInfo, LuConvertersOptions options);
12 13
     }
13 14
 
14 15
     public interface ILuObjectConverterDescriptor<TTypeFrom, TTypeTo> : ILuObjectConverterDescriptor

Loading…
Cancel
Save