Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "add generic mapper"

This reverts commit 1157e20.
  • Loading branch information...
commit 87611d83228a0e135851bd912d0d84c1a901c4e9 1 parent 608dd2c
testn authored October 26, 2010
BIN  redist/nunit.framework.dll
Binary file not shown
11,148  redist/nunit.framework.xml
3278 additions, 7870 deletions not shown
20  source/MongoDB/Configuration/Mapping/Auto/AutoMapper.cs
@@ -75,22 +75,12 @@ public AutoMapper(Func<Type, bool> filter)
75 75
         /// </summary>
76 76
         /// <param name = "classType">Type of the entity.</param>
77 77
         /// <returns></returns>
78  
-        private IClassMap CreateClassMap(Type classType)
79  
-        {
80  
-            ClassMapBase classMap;
81  
-            try
  78
+        private ClassMap CreateClassMap(Type classType){
  79
+            var classMap = new ClassMap(classType)
82 80
             {
83  
-                classMap = (ClassMapBase)Activator.CreateInstance(typeof(ClassMap<>).MakeGenericType(classType));
84  
-                classMap.CollectionName = _profile.GetCollectionName(classType);
85  
-                classMap.DiscriminatorAlias = _profile.GetDiscriminatorAlias(classType);
86  
-            }
87  
-            catch
88  
-            {
89  
-                classMap = new ClassMap(classType) {
90  
-                    CollectionName = _profile.GetCollectionName(classType),
91  
-                    DiscriminatorAlias = _profile.GetDiscriminatorAlias(classType)
92  
-                };
93  
-            }
  81
+                CollectionName = _profile.GetCollectionName(classType),
  82
+                DiscriminatorAlias = _profile.GetDiscriminatorAlias(classType)
  83
+            };
94 84
             //if(!classType.IsInterface && !classType.IsAbstract)
95 85
             //    classMap.Discriminator = _profile.GetDiscriminator(classType);
96 86
 
41  source/MongoDB/Configuration/Mapping/Model/ClassMap.cs
... ...
@@ -1,19 +1,17 @@
1 1
 using System;
2  
-using System.Linq;
3 2
 
4 3
 namespace MongoDB.Configuration.Mapping.Model
5 4
 {
6 5
     /// <summary>
7  
-    /// 
8 6
     /// </summary>
9 7
     public class ClassMap : ClassMapBase
10 8
     {
11 9
         /// <summary>
12  
-        ///   Initializes a new instance of the <see cref = "ClassMap&lt;T&gt;" /> class.
  10
+        ///   Initializes a new instance of the <see cref = "ClassMap" /> class.
13 11
         /// </summary>
14  
-        public ClassMap(Type type)
15  
-            : base(type)
16  
-        {
  12
+        /// <param name = "classType">Type of the entity.</param>
  13
+        public ClassMap(Type classType)
  14
+            : base(classType){
17 15
         }
18 16
 
19 17
         /// <summary>
@@ -46,37 +44,8 @@ public ClassMap(Type type)
46 44
         /// <value>
47 45
         ///   <c>true</c> if this class map is a subclass; otherwise, <c>false</c>.
48 46
         /// </value>
49  
-        public override bool IsSubClass
50  
-        {
  47
+        public override bool IsSubClass{
51 48
             get { return false; }
52 49
         }
53  
-
54  
-    }
55  
-
56  
-    /// <summary>
57  
-    /// </summary>
58  
-    public class ClassMap<T> : ClassMap where T:new()
59  
-    {
60  
-        /// <summary>
61  
-        ///   Initializes a new instance of the <see cref = "ClassMap&lt;T&gt;" /> class.
62  
-        /// </summary>
63  
-        public ClassMap()
64  
-            : base(typeof(T))
65  
-        {
66  
-        }
67  
-
68  
-        /// <summary>
69  
-        /// Creates an instance of the entity.
70  
-        /// </summary>
71  
-        /// <returns>a new entity instance</returns>
72  
-        public override object CreateInstance()
73  
-        {
74  
-            T instance = new T();
75  
-
76  
-            //initialize all default values in case something isn't specified when reader the document.
77  
-            foreach (var memberMap in MemberMaps.Where(x => x.DefaultValue != null))
78  
-                memberMap.SetValue(instance, memberMap.DefaultValue);
79  
-            return instance;
80  
-        }
81 50
     }
82 51
 }
2  source/MongoDB/Configuration/Mapping/Model/ClassMapBase.cs
@@ -148,7 +148,7 @@ private void EnsureCreator()
148 148
         ///   Creates an instance of the entity.
149 149
         /// </summary>
150 150
         /// <returns></returns>
151  
-        public virtual object CreateInstance()
  151
+        public object CreateInstance()
152 152
         {
153 153
             if(!_hasProtectedOrPublicConstructor)
154 154
                 throw new MissingMethodException("No public or protected constructor found on type " + ClassType.FullName);

0 notes on commit 87611d8

Please sign in to comment.
Something went wrong with that request. Please try again.