Forum Xamarin.iOS

How to cast objects from binding library?

I'm using BindingLibrary for player and I've following interfaces in ApiDefinition file:

// @protocol MediaRepresentationProtocol
public interface MediaRepresentationProtocol
// @required @property (readonly, nonatomic) NSInteger representationIndex
nint RepresentationIndex { get; }

// @required @property (readonly, nonatomic) MediaStream * parentStream;
MediaStream ParentStream { get; }

// @required @property (readonly, nonatomic) NSUInteger fourCC;
nuint FourCC { get; }

// @required @property (readonly, nonatomic) NSUInteger bitRate;
nuint BitRate { get; }

// @required @property (getter = isEnabled, nonatomic) BOOL enabled;
bool Enabled { [Bind("isEnabled")] get; set; }


// @public interface AudioInfo : NSObject
public interface AudioInfo : MediaRepresentationProtocol
// @property (readonly, nonatomic) NSUInteger samplingRate;
nuint SamplingRate { get; }

// @property (readonly, nonatomic) NSUInteger channels;
nuint Channels { get; }

// @property (readonly, nonatomic) NSUInteger bitPerSample;
nuint BitPerSample { get; }

// @property (readonly, nonatomic) NSUInteger packetSize;
nuint PacketSize { get; }

// @property (readonly, nonatomic) NSUInteger audioTag;
nuint AudioTag { get; }

// @property (readonly, nonatomic) NSString * language;
string Language { get; }


Now in my C# code, I'm using native method which returns array of MediaRepresentationProtocol objects. Actually in this case, there are really AudioInfo objects (I see this in debugger). How Can I cast MediaRepresenationProtocol to AudioInfo in case if the second one is not deriving (in C#) from the first one?
Output objects both implements IMediaRepresentationProtocol interface which is generated in Xamarin.

Sign In or Register to comment.