I have an object of type 'System.Windows.Documents.TextSegment' in an object of type Object. The TextSegment-Struct i can not use in my code, because it's internal code of the .net-framework.
What I want to do is, accessing the Start- and End-Property in the object of type TextSegment. I tried it by reflection with the following code:
// This object is of type TextSegment
object textSegment = segments[0];
FieldInfo info = textSegment.GetType().GetField("_start", BindingFlags.IgnoreCase |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance| BindingFlags.Static;
Now I don't know how to access the value of the FieldInfo.
I tried it with the following codes:
object value1 = info.GetValue(segments[0]);
object value2 = info.GetValue(null);
but nothing worked.
How can i get the value of the TextSegment?