本文整理汇总了C#中Request.DescriptionAs方法的典型用法代码示例。如果您正苦于以下问题:C# Request.DescriptionAs方法的具体用法?C# Request.DescriptionAs怎么用?C# Request.DescriptionAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.DescriptionAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fetch
public IObservable<Unit> Fetch (Request request)
{
return Observable.Create<Unit> (o => {
var description = request.DescriptionAs<ScaledDescription> ();
var url = new NSUrl (description.AbsoluteSourceUrl.AbsoluteUri);
var disp = new CancellationDisposable ();
var token = disp.Token;
Task.Factory.StartNew (() => {
using (var source = CGImageSource.FromUrl (url)) {
if (source.Handle == IntPtr.Zero)
throw new Exception (string.Format ("Could not create source for '{0}'", url));
var sourceSize = ImageHelper.Measure (source);
int maxPixelSize = GetMaxPixelSize (sourceSize, description.Size);
using (var scaled = CreateThumbnail (source, maxPixelSize, token))
using (var cropped = ScaleAndCrop (scaled, description.Size, description.Mode, token))
SaveToRequest (cropped, source.TypeIdentifier, request);
o.OnCompleted ();
}
}, token).RouteExceptions (o);
return disp;
});
}
示例2: Fetch
public IObservable<Unit> Fetch (Request request)
{
var description = request.DescriptionAs<AssetDescription> ();
return (description.Kind == AssetDescription.AssetImageKind.Thumbnail)
? SaveThumbnail (request)
: SaveFullResolutionImage (request);
}