public T FromEntity <T>(IMediaSourceEntity entity) where T : IMediaSource { IMediaSource result = null; MediaFileEntity fileEntity = entity as MediaFileEntity; if (fileEntity != null) { var fileSource = new FileMediaSource(fileEntity); result = fileSource; } else { ChannelInfo ci = entity as ChannelInfo; if (ci != null) { var channelSource = new ChannelMediaSource(ci); result = channelSource; } else { throw new ArgumentException(); } } return((T)result); }
public static IMediaSource ToMediaSource(this MediaSourceEntity entity, PlaybillItemEntity billItemEntity) { IMediaSource result = null; MediaFileEntity fileEntity = entity as MediaFileEntity; if (fileEntity != null) { var fileSource = new FileMediaSource(fileEntity); fileSource.AudioGain = billItemEntity.AudioGain; result = fileSource; } else { ChannelInfo ci = entity as ChannelInfo; if (ci != null) { var channelSource = new ChannelMediaSource(ci); result = channelSource; } else { throw new ArgumentException(); } } return(result); }
//public override IMediaSource Clone() //{ // var result = new ChannelMediaSource(this.Channel); // result.Id = this.Id; // return result; //} public override bool Equals(IMediaSource other) { ChannelMediaSource temp = other as ChannelMediaSource; return(temp != null && temp.Id == this.Id); }