Since IField object may contain items and children subobjects, it might look complicated to iterate over the fields.
Use the following code to display all fields inside IDocument:
private void AppendToResult(IField field, StringBuilder result)
{
if (field.Value != null)
{
result.AppendFormat("{0} = {1}\n", field.FullName, field.Value.AsText.Text);
return;
}
if (field.Children != null)
{
foreach (IField childField in field.Children)
{
AppendToResult(childField, result);
}
}
if (field.Instances != null) {
foreach( IField instanceField in field.Instances)
{
AppendToResult(instanceField, result);
}
}
}
System.Text.StringBuilder result = new System.Text.StringBuilder();
FCEngine.IField documentAsField = (IField)document;
AppendToResult(documentAsField, result);
Comments
0 comments
Please sign in to leave a comment.