forked from samus/mongodb-csharp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to read and write mapped protected object property.
- Loading branch information
Showing
14 changed files
with
104 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
source/MongoDB/Configuration/Mapping/Auto/PublicMemberFinder.cs
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
source/MongoDB/Configuration/Mapping/Auto/PublicOrProtectedMemberFinder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace MongoDB.Configuration.Mapping.Auto | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class PublicOrProtectedMemberFinder : IMemberFinder | ||
{ | ||
///<summary> | ||
///</summary> | ||
public static readonly PublicOrProtectedMemberFinder Instance = new PublicOrProtectedMemberFinder(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PublicOrProtectedMemberFinder"/> class. | ||
/// </summary> | ||
private PublicOrProtectedMemberFinder() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Finds the members. | ||
/// </summary> | ||
/// <param name="type">The type.</param> | ||
/// <returns></returns> | ||
public IEnumerable<MemberInfo> FindMembers(Type type) | ||
{ | ||
foreach (var prop in type.GetProperties(BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Public)) | ||
{ | ||
var getMethod = prop.GetGetMethod(true); | ||
var setMethod = prop.GetSetMethod(true); | ||
|
||
if(getMethod==null||setMethod==null) | ||
continue; | ||
|
||
if(getMethod.IsPrivate||setMethod.IsPrivate) | ||
continue; | ||
|
||
yield return prop; | ||
} | ||
|
||
foreach (var field in type.GetFields()) | ||
{ | ||
if (!field.IsInitOnly && !field.IsLiteral) | ||
yield return field; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
source/MongoDB/Serialization/Descriptors/BsonPropertyValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
source/MongoDB/Serialization/Descriptors/IPropertyDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters