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
/// ... somewhere in your cmdlet (might need to be PSCmdlet?) | |
private const BindingFlags BindingFlags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public; | |
// provided you have a tasty function to reflect private fields/properties | |
protected object TryGetProperty(object instance, string fieldName) { | |
// any access of a null object returns null. | |
if (instance == null || string.IsNullOrEmpty(fieldName)) { | |
return null; | |
} |