I am desperately trying to adapt an API from which I want to fetch a specific value out of an array and I can't seem capable of doing so.
Specifically, I am trying to fetch a custom field name and value out of the API where the name is Controller and the value is whatever the user gave it a value of (its a string value).
I order to get to this, I need to use what is called an IGame interface, which has several properties and methods within it. All of the properties are used with game proceeded with the name of the property. For example, game.title or game.Platform.
So, doing this.Controller.Text = game.Title; outputs the game title to the UI. So far, so good.
My problem comes when using the methods, whering the custom fields lie. I have to use GetAllCustomFields which has the syntax of ICustomField[] GetAllCustomFields(). The return value is ICustomField[] whose syntax in turn is public interface ICustomField with the properties of GameId, Name, Value.
Unfortunately, the API gives me no further information on actual usage so I'm left to try to figure it out but to no avail.
Here what i have so far:
public void OnSelectionChanged(FilterType filterType, string filterValue, IPlatform platform, IPlatformCategory category, IPlaylist playlist, IGame game)
{
if (game == null)
{
this.Controller.Text = "HellO!";
}
else
{
foreach (string field in game.GetAllCustomFields(ICustomField[Name]))
{
this.Controller.Text = "The " + Name + " is " + Value;
}
}
}
XAML
<Grid>
<TextBox x:Name="Controller" />
</Grid>
Can someone help me restructure the foreach so it actually works?
foreach (ICustomField field in game.GetAllCustomFields())in your for loop, and thenthis.Controller.Text = "The " + field.Name + " is " + field.Value;