本文整理汇总了C#中ResizeSettings.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ResizeSettings.ToString方法的具体用法?C# ResizeSettings.ToString怎么用?C# ResizeSettings.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResizeSettings
的用法示例。
在下文中一共展示了ResizeSettings.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCropValues
public void TestCropValues()
{
ResizeSettings s = new ResizeSettings();
s.CropBottomRight = new System.Drawing.PointF(50, 50);
s.CropTopLeft = new System.Drawing.PointF(0, 0);
Assert.AreEqual<string>( "?crop=0,0,50,50", s.ToString());
s.CropMode = CropMode.Auto;
Assert.AreEqual<string>("?crop=auto", s.ToString());
}
示例2: GetImageCachePath
public string GetImageCachePath(string url, ResizeSettings settings)
{
string imageDir = Path.GetDirectoryName(url);
if (imageDir == null)
{
imageDir = string.Empty;
}
string hasedProperties = CreateMd5Hash(settings.ToString());
string cachedFileName = string.Format("{0}/{1}-{2}.{3}",
GetFolderHash(imageDir),
Path.GetFileNameWithoutExtension(url),
hasedProperties,
GetCleanFileExtension(url));
string cachedImagePath = string.Concat(Consts.CacheFolderPath, "/", cachedFileName.TrimStart('/', '\\'));
return cachedImagePath;
}
示例3: GetMemCachedBitmap
/// <summary>
/// Loads or caches a bitmap, using asp.net's cache (when available)
/// </summary>
/// <param name="query"></param>
/// <param name="virtualPath"></param>
/// <param name="onlyLoadIfCacheExists">Whether to load the image when
/// no cache is available. Pass <c>true</c> for pre-fetching, and
/// <c>false</c> if the image is needed immediately.</param>
/// <returns>Returns the Bitmap. If no cache is available, and
/// <c>onlyLoadIfCacheExists</c> is <c>true</c>, returns <c>null</c>
/// rather than loading the Bitmap.</returns>
public Bitmap GetMemCachedBitmap(string virtualPath, ResizeSettings query, bool onlyLoadIfCacheExists = false)
{
//If not ASP.NET, don't cache.
if (HttpContext.Current == null) return onlyLoadIfCacheExists ? null : c.CurrentImageBuilder.LoadImage(virtualPath, query);
string key = virtualPath.ToLowerInvariant() + query.ToString();
Bitmap b = HttpContext.Current.Cache[key] as Bitmap;
if (b != null) return b;
try
{
b = c.CurrentImageBuilder.LoadImage(virtualPath, query);
}
catch (FileNotFoundException fe)
{
throw new ImageProcessingException(500, "Failed to located watermark " + virtualPath, "Failed to located a watermarking file", fe);
}
//Query VPPs for cache dependency. TODO: Add support for IVirtualImageProviders to customize cache dependencies.
CacheDependency cd = null;
if (HostingEnvironment.VirtualPathProvider != null) cd = HostingEnvironment.VirtualPathProvider.GetCacheDependency(virtualPath, new string[] { }, DateTime.UtcNow);
HttpContext.Current.Cache.Insert(key, b, cd);
return b;
}
示例4: CreateSettingsHash
private string CreateSettingsHash(ResizeSettings settings)
{
if (settings.Count == 2 && settings.MaxWidth > 0 && settings.MaxWidth == settings.MaxHeight)
{
return settings.MaxWidth.ToString();
}
return settings.ToString().Hash(Encoding.ASCII);
}
示例5: GetMemCachedBitmap
/// <summary>
/// Loads a bitmap, cached using asp.net's cache
/// </summary>
/// <param name="query"></param>
/// <param name="virtualPath"></param>
/// <returns></returns>
public Bitmap GetMemCachedBitmap(string virtualPath, ResizeSettings query)
{
//If not ASP.NET, don't cache.
if (HttpContext.Current == null) return c.CurrentImageBuilder.LoadImage(virtualPath, query);
string key = virtualPath.ToLowerInvariant() + query.ToString();
Bitmap b = HttpContext.Current.Cache[key] as Bitmap;
if (b != null) return b;
b = c.CurrentImageBuilder.LoadImage(virtualPath, query);
//Query VPPs for cache dependency. TODO: Add support for IVirtualImageProviders to customize cache dependencies.
CacheDependency cd = null;
if (HostingEnvironment.VirtualPathProvider != null) cd = HostingEnvironment.VirtualPathProvider.GetCacheDependency(virtualPath, new string[] { }, DateTime.UtcNow);
HttpContext.Current.Cache.Insert(key, b, cd);
return b;
}