Using a PrivateObject, I'm trying to create an instance of the ItemChange class (found here). Looking through the debugger as well as the object browser in Visual Studio 2008 I can't seem to find anything related to the ItemId property other than a setter. Below is the code I am using.
var itemChange = new PrivateObject(typeof(ItemChange));
itemChange.SetFieldOrProperty("ChangeType", _fixture.CreateAnonymous<ChangeType>());
itemChange.SetFieldOrProperty("ItemId", _fixture.CreateAnonymous<ItemId>());
The error I receive is:
System.MissingMethodException : Method 'Microsoft.Exchange.WebServices.Data.ItemChange.ItemId' not found.
I've tried variations of BindingFlags, however nothing seems to help. How can I set a property that has no setter and only a getter?
Edit
Regarding my comments, the other inline class that I can create a PrivateObject object instance and set the ItemId is the ItemEvent class (found here). This class was easy because when I was debugging and added the class to my watch list I could see itemId as a private variable. However, performing the same steps on the ItemChange class I cannot find any traces of an ItemId field other than the property itself that only has a setter. This is where I'm stumped on how to set this property.
Lastly, I don't have access to a tool that would allow me to decompile the class and see what is what.
PrivateObjectwas a wrapper around all that reflection stuff, no?object.