Reputation: 918
How can I access the factory property in MediaMuxer inside this MergeChannels extension method? is it possible?
public class MediaMuxer : IMediaMuxer
{
protected readonly IProcessWorkerFactory factory;
public MediaMuxer(IProcessWorkerFactory processFactory);
}
Upvotes: 0
Views: 93
Reputation: 1500625
No, you can't access the factory
field, because it's protected - it would only be accessible from a subclass of MediaMuxer
, and extension methods can only be declared in static classes, so those can't be subclasses of MediaMuxer
. (And even then, it's only accessible within an instance of the subclass in which the accessing code is written - not just any arbitrary MediaMuxer
.)
Additionally, even if that were public, muxer
is declared to be of type IMediaMuxer
, not MediaMuxer
, so you'll only have access to members declared in IMediaMuxer
. So basically:
IMediaMuxer
, that would do itMediaMuxer
and change your extension method's first parameter to be of type MediaMuxer
.Upvotes: 3