使用Automapper进行通用映射

时间:2018-03-20 10:07:21

标签: automapper mappings

我想创建一个通用/通用映射,它将等同于以下映射但使用单行。

cfg.CreateMap<TValue, PropertyModel<TValue>>().ConvertUsing<ValueToPropertyModelConverter<TValue>>();

我会想象像

这样的东西
// adding video URL in AVPlayerItem //
self.avPlayerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:mediaURL]];
// frame declaration of player layer //
CGRect videoRect;
videoRect = CGRectMake(0,0,[[UIScreen mainScreen]bounds].size.width,[[UIScreen mainScreen]bounds].size.height);
// initilization of AVPlayer with AVPlayerItem and AVPlayerLayer  //
self.avPlayer = [AVPlayer playerWithPlayerItem:self.avPlayerItem];
self.avLPlayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
[_avLPlayer setFrame:videoRect];
[_avLPlayer setVideoGravity:AVLayerVideoGravityResizeAspect];
_avLPlayer.opacity = 1;
_avPlayer.allowsExternalPlayback = NO;
[_avPlayer setMuted:NO];
_avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[AVAudioSession sharedInstance]setCategory: AVAudioSessionCategoryPlayback error: nil];
[self.viewForShowVideo.layer addSublayer:_avLPlayer];
[_avPlayer seekToTime:kCMTimeZero];
[_avPlayer play];
// Adding a thumbnail image and Activity Indicator in view   // 
loadingIndicatorForVideo = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 177,323)];
[loadingIndicatorForVideo startAnimating];
loadingIndicatorForVideo.center = self.center;
loadingIndicatorForVideo.color = [UIColor whiteColor];
[loadingIndicatorForVideo setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[_imgForVideoThumbnil addSubview:loadingIndicatorForVideo];
[_imgForVideoThumbnil sd_setImageWithURL:[NSURL URLWithString:mediaDataModel.strThumbUrl]];
[_avPlayer addObserver:self forKeyPath:@"status" options:0 context:nil];
// Orientation management according to video //
if ([strMediaOrientation isEqualToString:@"1"] || [strMediaOrientation isEqualToString:@"landscape"]) {
self.avLPlayer.transform = CATransform3DMakeRotation(90.0 / 180.0 * M_PI, 0.0, 0.0, 1.0);
[_avLPlayer setFrame:self.avLPlayer.bounds];
UIImage * landscapeImage = _imgForVideoThumbnil.image;
UIImage * portraitImage = [[UIImage alloc] initWithCGImage: landscapeImage.CGImage scale: 1.0 orientation: UIImageOrientationRight];
[_imgForVideoThumbnil setImage:portraitImage];
loadingIndicatorForVideo.center = self.center;
}

有什么想法吗?

谢谢!

Riana

0 个答案:

没有答案
相关问题