BsonMemberMap.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /* Copyright 2010-2016 MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.Linq.Expressions;
  17. using System.Reflection;
  18. #if !ENABLE_IL2CPP
  19. using System.Reflection.Emit;
  20. #endif
  21. using MongoDB.Bson.Serialization.Serializers;
  22. namespace MongoDB.Bson.Serialization
  23. {
  24. /// <summary>
  25. /// Represents the mapping between a field or property and a BSON element.
  26. /// </summary>
  27. public class BsonMemberMap
  28. {
  29. // private fields
  30. private readonly BsonClassMap _classMap;
  31. private readonly MemberInfo _memberInfo;
  32. private readonly Type _memberType;
  33. private readonly bool _memberTypeIsBsonValue;
  34. private string _elementName;
  35. private bool _frozen; // once a class map has been frozen no further changes are allowed
  36. private int _order;
  37. private Func<object, object> _getter;
  38. private Action<object, object> _setter;
  39. private volatile IBsonSerializer _serializer;
  40. private IIdGenerator _idGenerator;
  41. private bool _isRequired;
  42. private Func<object, bool> _shouldSerializeMethod;
  43. private bool _ignoreIfDefault;
  44. private bool _ignoreIfNull;
  45. private object _defaultValue;
  46. private Func<object> _defaultValueCreator;
  47. private bool _defaultValueSpecified;
  48. // constructors
  49. /// <summary>
  50. /// Initializes a new instance of the BsonMemberMap class.
  51. /// </summary>
  52. /// <param name="classMap">The class map this member map belongs to.</param>
  53. /// <param name="memberInfo">The member info.</param>
  54. public BsonMemberMap(BsonClassMap classMap, MemberInfo memberInfo)
  55. {
  56. _classMap = classMap;
  57. _memberInfo = memberInfo;
  58. _memberType = BsonClassMap.GetMemberInfoType(memberInfo);
  59. _memberTypeIsBsonValue = typeof(BsonValue).GetTypeInfo().IsAssignableFrom(_memberType);
  60. Reset();
  61. }
  62. // public properties
  63. /// <summary>
  64. /// Gets the class map that this member map belongs to.
  65. /// </summary>
  66. public BsonClassMap ClassMap
  67. {
  68. get { return _classMap; }
  69. }
  70. /// <summary>
  71. /// Gets the name of the member.
  72. /// </summary>
  73. public string MemberName
  74. {
  75. get { return _memberInfo.Name; }
  76. }
  77. /// <summary>
  78. /// Gets the type of the member.
  79. /// </summary>
  80. public Type MemberType
  81. {
  82. get { return _memberType; }
  83. }
  84. /// <summary>
  85. /// Gets whether the member type is a BsonValue.
  86. /// </summary>
  87. public bool MemberTypeIsBsonValue
  88. {
  89. get { return _memberTypeIsBsonValue; }
  90. }
  91. /// <summary>
  92. /// Gets the name of the element.
  93. /// </summary>
  94. public string ElementName
  95. {
  96. get { return _elementName; }
  97. }
  98. /// <summary>
  99. /// Gets the serialization order.
  100. /// </summary>
  101. public int Order
  102. {
  103. get { return _order; }
  104. }
  105. /// <summary>
  106. /// Gets the member info.
  107. /// </summary>
  108. public MemberInfo MemberInfo
  109. {
  110. get { return _memberInfo; }
  111. }
  112. /// <summary>
  113. /// Gets the getter function.
  114. /// </summary>
  115. public Func<object, object> Getter
  116. {
  117. get
  118. {
  119. if (_getter == null)
  120. {
  121. _getter = GetGetter();
  122. }
  123. return _getter;
  124. }
  125. }
  126. /// <summary>
  127. /// Gets the setter function.
  128. /// </summary>
  129. public Action<object, object> Setter
  130. {
  131. get
  132. {
  133. if (_setter == null)
  134. {
  135. if (_memberInfo is FieldInfo)
  136. {
  137. _setter = GetFieldSetter();
  138. }
  139. else
  140. {
  141. _setter = GetPropertySetter();
  142. }
  143. }
  144. return _setter;
  145. }
  146. }
  147. /// <summary>
  148. /// Gets the Id generator.
  149. /// </summary>
  150. public IIdGenerator IdGenerator
  151. {
  152. get { return _idGenerator; }
  153. }
  154. /// <summary>
  155. /// Gets whether a default value was specified.
  156. /// </summary>
  157. public bool IsDefaultValueSpecified
  158. {
  159. get { return _defaultValueSpecified; }
  160. }
  161. /// <summary>
  162. /// Gets whether an element is required for this member when deserialized.
  163. /// </summary>
  164. public bool IsRequired
  165. {
  166. get { return _isRequired; }
  167. }
  168. /// <summary>
  169. /// Gets the method that will be called to determine whether the member should be serialized.
  170. /// </summary>
  171. public Func<object, bool> ShouldSerializeMethod
  172. {
  173. get { return _shouldSerializeMethod; }
  174. }
  175. /// <summary>
  176. /// Gets whether default values should be ignored when serialized.
  177. /// </summary>
  178. public bool IgnoreIfDefault
  179. {
  180. get { return _ignoreIfDefault; }
  181. }
  182. /// <summary>
  183. /// Gets whether null values should be ignored when serialized.
  184. /// </summary>
  185. public bool IgnoreIfNull
  186. {
  187. get { return _ignoreIfNull; }
  188. }
  189. /// <summary>
  190. /// Gets the default value.
  191. /// </summary>
  192. public object DefaultValue
  193. {
  194. get { return _defaultValueCreator != null ? _defaultValueCreator() : _defaultValue; }
  195. }
  196. /// <summary>
  197. /// Gets whether the member is readonly.
  198. /// </summary>
  199. /// <remarks>
  200. /// Readonly indicates that the member is written to the database, but not read from the database.
  201. /// </remarks>
  202. public bool IsReadOnly
  203. {
  204. get
  205. {
  206. if (_memberInfo is FieldInfo)
  207. {
  208. var field = (FieldInfo)_memberInfo;
  209. return field.IsInitOnly || field.IsLiteral;
  210. }
  211. else if (_memberInfo is PropertyInfo)
  212. {
  213. var property = (PropertyInfo)_memberInfo;
  214. return !property.CanWrite;
  215. }
  216. else
  217. {
  218. throw new NotSupportedException(
  219. string.Format("Only fields and properties are supported by BsonMemberMap. The member {0} of class {1} is a {2}.",
  220. _memberInfo.Name,
  221. _memberInfo.DeclaringType.Name,
  222. _memberInfo is FieldInfo ? "field" : "property"));
  223. }
  224. }
  225. }
  226. // public methods
  227. /// <summary>
  228. /// Applies the default value to the member of an object.
  229. /// </summary>
  230. /// <param name="obj">The object.</param>
  231. public void ApplyDefaultValue(object obj)
  232. {
  233. if (_defaultValueSpecified)
  234. {
  235. this.Setter(obj, DefaultValue);
  236. }
  237. }
  238. /// <summary>
  239. /// Freezes this instance.
  240. /// </summary>
  241. public void Freeze()
  242. {
  243. _frozen = true;
  244. }
  245. /// <summary>
  246. /// Gets the serializer.
  247. /// </summary>
  248. /// <returns>The serializer.</returns>
  249. public IBsonSerializer GetSerializer()
  250. {
  251. if (_serializer == null)
  252. {
  253. // return special serializer for BsonValue members that handles the _csharpnull representation
  254. if (_memberTypeIsBsonValue)
  255. {
  256. var wrappedSerializer = BsonSerializer.LookupSerializer(_memberType);
  257. var isBsonArraySerializer = wrappedSerializer is IBsonArraySerializer;
  258. var isBsonDocumentSerializer = wrappedSerializer is IBsonDocumentSerializer;
  259. Type csharpNullSerializerDefinition;
  260. if (isBsonArraySerializer && isBsonDocumentSerializer)
  261. {
  262. csharpNullSerializerDefinition = typeof(BsonValueCSharpNullArrayAndDocumentSerializer<>);
  263. }
  264. else if (isBsonArraySerializer)
  265. {
  266. csharpNullSerializerDefinition = typeof(BsonValueCSharpNullArraySerializer<>);
  267. }
  268. else if (isBsonDocumentSerializer)
  269. {
  270. csharpNullSerializerDefinition = typeof(BsonValueCSharpNullDocumentSerializer<>);
  271. }
  272. else
  273. {
  274. csharpNullSerializerDefinition = typeof(BsonValueCSharpNullSerializer<>);
  275. }
  276. var csharpNullSerializerType = csharpNullSerializerDefinition.MakeGenericType(_memberType);
  277. var csharpNullSerializer = (IBsonSerializer)Activator.CreateInstance(csharpNullSerializerType, wrappedSerializer);
  278. _serializer = csharpNullSerializer;
  279. }
  280. else
  281. {
  282. _serializer = BsonSerializer.LookupSerializer(_memberType);
  283. }
  284. }
  285. return _serializer;
  286. }
  287. /// <summary>
  288. /// Resets the member map back to its initial state.
  289. /// </summary>
  290. /// <returns>The member map.</returns>
  291. public BsonMemberMap Reset()
  292. {
  293. if (_frozen) { ThrowFrozenException(); }
  294. _defaultValue = GetDefaultValue(_memberType);
  295. _defaultValueCreator = null;
  296. _defaultValueSpecified = false;
  297. _elementName = _memberInfo.Name;
  298. _idGenerator = null;
  299. _ignoreIfDefault = false;
  300. _ignoreIfNull = false;
  301. _isRequired = false;
  302. _order = int.MaxValue;
  303. _serializer = null;
  304. _shouldSerializeMethod = null;
  305. return this;
  306. }
  307. /// <summary>
  308. /// Sets the default value creator.
  309. /// </summary>
  310. /// <param name="defaultValueCreator">The default value creator (note: the supplied delegate must be thread safe).</param>
  311. /// <returns>The member map.</returns>
  312. public BsonMemberMap SetDefaultValue(Func<object> defaultValueCreator)
  313. {
  314. if (defaultValueCreator == null)
  315. {
  316. throw new ArgumentNullException("defaultValueCreator");
  317. }
  318. if (_frozen) { ThrowFrozenException(); }
  319. _defaultValue = defaultValueCreator(); // need an instance to compare against
  320. _defaultValueCreator = defaultValueCreator;
  321. _defaultValueSpecified = true;
  322. return this;
  323. }
  324. /// <summary>
  325. /// Sets the default value.
  326. /// </summary>
  327. /// <param name="defaultValue">The default value.</param>
  328. /// <returns>The member map.</returns>
  329. public BsonMemberMap SetDefaultValue(object defaultValue)
  330. {
  331. if (_frozen) { ThrowFrozenException(); }
  332. _defaultValue = defaultValue;
  333. _defaultValueCreator = null;
  334. _defaultValueSpecified = true;
  335. return this;
  336. }
  337. /// <summary>
  338. /// Sets the name of the element.
  339. /// </summary>
  340. /// <param name="elementName">The name of the element.</param>
  341. /// <returns>The member map.</returns>
  342. public BsonMemberMap SetElementName(string elementName)
  343. {
  344. if (elementName == null)
  345. {
  346. throw new ArgumentNullException("elementName");
  347. }
  348. if (elementName.IndexOf('\0') != -1)
  349. {
  350. throw new ArgumentException("Element names cannot contain nulls.", "elementName");
  351. }
  352. if (_frozen) { ThrowFrozenException(); }
  353. _elementName = elementName;
  354. return this;
  355. }
  356. /// <summary>
  357. /// Sets the Id generator.
  358. /// </summary>
  359. /// <param name="idGenerator">The Id generator.</param>
  360. /// <returns>The member map.</returns>
  361. public BsonMemberMap SetIdGenerator(IIdGenerator idGenerator)
  362. {
  363. if (_frozen) { ThrowFrozenException(); }
  364. _idGenerator = idGenerator;
  365. return this;
  366. }
  367. /// <summary>
  368. /// Sets whether default values should be ignored when serialized.
  369. /// </summary>
  370. /// <param name="ignoreIfDefault">Whether default values should be ignored when serialized.</param>
  371. /// <returns>The member map.</returns>
  372. public BsonMemberMap SetIgnoreIfDefault(bool ignoreIfDefault)
  373. {
  374. if (_frozen) { ThrowFrozenException(); }
  375. if (ignoreIfDefault && _ignoreIfNull)
  376. {
  377. throw new InvalidOperationException("IgnoreIfDefault and IgnoreIfNull are mutually exclusive. Choose one or the other.");
  378. }
  379. _ignoreIfDefault = ignoreIfDefault;
  380. return this;
  381. }
  382. /// <summary>
  383. /// Sets whether null values should be ignored when serialized.
  384. /// </summary>
  385. /// <param name="ignoreIfNull">Wether null values should be ignored when serialized.</param>
  386. /// <returns>The member map.</returns>
  387. public BsonMemberMap SetIgnoreIfNull(bool ignoreIfNull)
  388. {
  389. if (_frozen) { ThrowFrozenException(); }
  390. if (ignoreIfNull && _ignoreIfDefault)
  391. {
  392. throw new InvalidOperationException("IgnoreIfDefault and IgnoreIfNull are mutually exclusive. Choose one or the other.");
  393. }
  394. _ignoreIfNull = ignoreIfNull;
  395. return this;
  396. }
  397. /// <summary>
  398. /// Sets whether an element is required for this member when deserialized
  399. /// </summary>
  400. /// <param name="isRequired">Whether an element is required for this member when deserialized</param>
  401. /// <returns>The member map.</returns>
  402. public BsonMemberMap SetIsRequired(bool isRequired)
  403. {
  404. if (_frozen) { ThrowFrozenException(); }
  405. _isRequired = isRequired;
  406. return this;
  407. }
  408. /// <summary>
  409. /// Sets the serialization order.
  410. /// </summary>
  411. /// <param name="order">The serialization order.</param>
  412. /// <returns>The member map.</returns>
  413. public BsonMemberMap SetOrder(int order)
  414. {
  415. if (_frozen) { ThrowFrozenException(); }
  416. _order = order;
  417. return this;
  418. }
  419. /// <summary>
  420. /// Sets the serializer.
  421. /// </summary>
  422. /// <param name="serializer">The serializer.</param>
  423. /// <returns>
  424. /// The member map.
  425. /// </returns>
  426. /// <exception cref="System.ArgumentNullException">serializer</exception>
  427. /// <exception cref="System.ArgumentException">serializer</exception>
  428. public BsonMemberMap SetSerializer(IBsonSerializer serializer)
  429. {
  430. if (serializer == null)
  431. {
  432. throw new ArgumentNullException("serializer");
  433. }
  434. if (serializer.ValueType != _memberType)
  435. {
  436. var message = string.Format("Value type of serializer is {0} and does not match member type {1}.", serializer.ValueType.FullName, _memberType.FullName);
  437. throw new ArgumentException(message, "serializer");
  438. }
  439. if (_frozen) { ThrowFrozenException(); }
  440. _serializer = serializer;
  441. return this;
  442. }
  443. /// <summary>
  444. /// Sets the method that will be called to determine whether the member should be serialized.
  445. /// </summary>
  446. /// <param name="shouldSerializeMethod">The method.</param>
  447. /// <returns>The member map.</returns>
  448. public BsonMemberMap SetShouldSerializeMethod(Func<object, bool> shouldSerializeMethod)
  449. {
  450. if (_frozen) { ThrowFrozenException(); }
  451. _shouldSerializeMethod = shouldSerializeMethod;
  452. return this;
  453. }
  454. /// <summary>
  455. /// Determines whether a value should be serialized
  456. /// </summary>
  457. /// <param name="obj">The object.</param>
  458. /// <param name="value">The value.</param>
  459. /// <returns>True if the value should be serialized.</returns>
  460. public bool ShouldSerialize(object obj, object value)
  461. {
  462. if (_ignoreIfNull)
  463. {
  464. if (value == null)
  465. {
  466. return false; // don't serialize null
  467. }
  468. }
  469. if (_ignoreIfDefault)
  470. {
  471. if (object.Equals(_defaultValue, value))
  472. {
  473. return false; // don't serialize default value
  474. }
  475. }
  476. if (_shouldSerializeMethod != null && !_shouldSerializeMethod(obj))
  477. {
  478. // the _shouldSerializeMethod determined that the member shouldn't be serialized
  479. return false;
  480. }
  481. return true;
  482. }
  483. // private methods
  484. private static object GetDefaultValue(Type type)
  485. {
  486. var typeInfo = type.GetTypeInfo();
  487. if (typeInfo.IsEnum)
  488. {
  489. return Enum.ToObject(type, 0);
  490. }
  491. switch (Type.GetTypeCode(type))
  492. {
  493. case TypeCode.Empty:
  494. #if NET45
  495. case TypeCode.DBNull:
  496. #endif
  497. case TypeCode.String:
  498. break;
  499. case TypeCode.Object:
  500. if (typeInfo.IsValueType)
  501. {
  502. return Activator.CreateInstance(type);
  503. }
  504. break;
  505. case TypeCode.Boolean: return false;
  506. case TypeCode.Char: return '\0';
  507. case TypeCode.SByte: return (sbyte)0;
  508. case TypeCode.Byte: return (byte)0;
  509. case TypeCode.Int16: return (short)0;
  510. case TypeCode.UInt16: return (ushort)0;
  511. case TypeCode.Int32: return 0;
  512. case TypeCode.UInt32: return 0U;
  513. case TypeCode.Int64: return 0L;
  514. case TypeCode.UInt64: return 0UL;
  515. case TypeCode.Single: return 0F;
  516. case TypeCode.Double: return 0D;
  517. case TypeCode.Decimal: return 0M;
  518. case TypeCode.DateTime: return DateTime.MinValue;
  519. }
  520. return null;
  521. }
  522. private Action<object, object> GetFieldSetter()
  523. {
  524. var fieldInfo = (FieldInfo)_memberInfo;
  525. if (IsReadOnly)
  526. {
  527. var message = string.Format(
  528. "The field '{0} {1}' of class '{2}' is readonly. To avoid this exception, call IsReadOnly to ensure that setting a value is allowed.",
  529. fieldInfo.FieldType.FullName, fieldInfo.Name, fieldInfo.DeclaringType.FullName);
  530. throw new BsonSerializationException(message);
  531. }
  532. #if ENABLE_IL2CPP
  533. return (obj, value) => { fieldInfo.SetValue(obj, value); };
  534. #else
  535. var sourceType = fieldInfo.DeclaringType;
  536. var method = new DynamicMethod("Set" + fieldInfo.Name, null, new[] { typeof(object), typeof(object) }, true);
  537. var gen = method.GetILGenerator();
  538. gen.Emit(OpCodes.Ldarg_0);
  539. gen.Emit(OpCodes.Castclass, sourceType);
  540. gen.Emit(OpCodes.Ldarg_1);
  541. gen.Emit(OpCodes.Unbox_Any, fieldInfo.FieldType);
  542. gen.Emit(OpCodes.Stfld, fieldInfo);
  543. gen.Emit(OpCodes.Ret);
  544. return (Action<object, object>)method.CreateDelegate(typeof(Action<object, object>));
  545. #endif
  546. }
  547. private Func<object, object> GetGetter()
  548. {
  549. #if ENABLE_IL2CPP
  550. PropertyInfo propertyInfo = _memberInfo as PropertyInfo;
  551. if (propertyInfo != null)
  552. {
  553. MethodInfo getMethodInfo = propertyInfo.GetGetMethod();
  554. if (getMethodInfo == null)
  555. {
  556. var message = string.Format(
  557. "The property '{0} {1}' of class '{2}' has no 'get' accessor.",
  558. propertyInfo.PropertyType.FullName, propertyInfo.Name, propertyInfo.DeclaringType.FullName);
  559. throw new BsonSerializationException(message);
  560. }
  561. return (obj) => { return getMethodInfo.Invoke(obj, null); };
  562. }
  563. FieldInfo fieldInfo = _memberInfo as FieldInfo;
  564. return (obj) => { return fieldInfo.GetValue(obj); };
  565. #else
  566. var propertyInfo = _memberInfo as PropertyInfo;
  567. if (propertyInfo != null)
  568. {
  569. var getMethodInfo = propertyInfo.GetMethod;
  570. if (getMethodInfo == null)
  571. {
  572. var message = string.Format(
  573. "The property '{0} {1}' of class '{2}' has no 'get' accessor.",
  574. propertyInfo.PropertyType.FullName, propertyInfo.Name, propertyInfo.DeclaringType.FullName);
  575. throw new BsonSerializationException(message);
  576. }
  577. }
  578. // lambdaExpression = (obj) => (object) ((TClass) obj).Member
  579. var objParameter = Expression.Parameter(typeof(object), "obj");
  580. var lambdaExpression = Expression.Lambda<Func<object, object>>(
  581. Expression.Convert(
  582. Expression.MakeMemberAccess(
  583. Expression.Convert(objParameter, _memberInfo.DeclaringType),
  584. _memberInfo
  585. ),
  586. typeof(object)
  587. ),
  588. objParameter
  589. );
  590. return lambdaExpression.Compile();
  591. #endif
  592. }
  593. private Action<object, object> GetPropertySetter()
  594. {
  595. #if ENABLE_IL2CPP
  596. var propertyInfo = (PropertyInfo) _memberInfo;
  597. return (obj, value) => { propertyInfo.SetValue(obj, value); };
  598. #else
  599. var propertyInfo = (PropertyInfo)_memberInfo;
  600. var setMethodInfo = propertyInfo.SetMethod;
  601. if (IsReadOnly)
  602. {
  603. var message = string.Format(
  604. "The property '{0} {1}' of class '{2}' has no 'set' accessor. To avoid this exception, call IsReadOnly to ensure that setting a value is allowed.",
  605. propertyInfo.PropertyType.FullName, propertyInfo.Name, propertyInfo.DeclaringType.FullName);
  606. throw new BsonSerializationException(message);
  607. }
  608. // lambdaExpression = (obj, value) => ((TClass) obj).SetMethod((TMember) value)
  609. var objParameter = Expression.Parameter(typeof(object), "obj");
  610. var valueParameter = Expression.Parameter(typeof(object), "value");
  611. var lambdaExpression = Expression.Lambda<Action<object, object>>(
  612. Expression.Call(
  613. Expression.Convert(objParameter, _memberInfo.DeclaringType),
  614. setMethodInfo,
  615. Expression.Convert(valueParameter, _memberType)
  616. ),
  617. objParameter,
  618. valueParameter
  619. );
  620. return lambdaExpression.Compile();
  621. #endif
  622. }
  623. private void ThrowFrozenException()
  624. {
  625. var message = string.Format("Member map for {0}.{1} has been frozen and no further changes are allowed.", _classMap.ClassType.FullName, _memberInfo.Name);
  626. throw new InvalidOperationException(message);
  627. }
  628. }
  629. }