本文整理汇总了C#中Generator.Cache方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.Cache方法的具体用法?C# Generator.Cache怎么用?C# Generator.Cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator.Cache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearCache
/// <summary>
/// Clears the brush cache
/// </summary>
/// <remarks>
/// This is useful if you are using the <see cref="Cached"/> method to cache brushes and want to clear it
/// to conserve memory or resources.
/// </remarks>
/// <param name="generator">Generator to clear the brush cache for</param>
public static void ClearCache (Generator generator = null)
{
var cache = generator.Cache<BrushKey, SolidBrush>(cacheKey);
lock (cache) {
cache.Clear ();
}
}
示例2: ClearCache
/// <summary>
/// Clears the pen cache
/// </summary>
/// <remarks>
/// This is useful if you are using the <see cref="Cached"/> method to cache pens and want to clear it
/// to conserve memory or resources.
/// </remarks>
/// <param name="generator">Generator to clear the pen cache for</param>
public static void ClearCache (Generator generator = null)
{
var cache = generator.Cache<PenKey, Pen> (cacheKey);
lock (cache) {
cache.Clear ();
}
}
示例3: ClearCache
/// <summary>
/// Clears the cursor cache
/// </summary>
/// <remarks>
/// This is useful if you are using the <see cref="Cached"/> method to cache pens and want to clear it
/// to conserve memory or resources.
/// </remarks>
/// <param name="generator">Generator to clear the pen cache for</param>
public static void ClearCache (Generator generator = null)
{
var cache = generator.Cache<CursorType, Cursor> (cursorCache);
lock (cache) {
cache.Clear ();
}
}
示例4: GetCursor
static Cursor GetCursor (CursorType type, Generator generator = null)
{
var cache = generator.Cache<CursorType, Cursor> (cursorCache);
Cursor cursor;
lock (cache) {
if (!cache.TryGetValue (type, out cursor)) {
cursor = new Cursor (generator, type);
cache [type] = cursor;
}
}
return cursor;
}
示例5: GetFont
static Font GetFont (FontFamily family, float size, FontStyle style, Generator generator)
{
var cache = generator.Cache<FontCacheKey, Font>(cacheKey);
Font font;
lock (cache) {
var key = new FontCacheKey (family, size, style);
if (!cache.TryGetValue (key, out font)) {
font = new Font (family, size, style, generator);
cache.Add (key, font);
}
}
return font;
}
示例6: GetBrush
static Brush GetBrush (Color color, Generator generator)
{
var cache = generator.Cache<BrushKey, Brush>(cacheKey);
Brush brush;
lock (cache) {
var key = new BrushKey (color.ToArgb ());
if (!cache.TryGetValue (key, out brush)) {
brush = new SolidBrush (color, generator);
cache.Add (key, brush);
}
}
return brush;
}
示例7: GetPen
static Pen GetPen (Generator generator, Color color, float thickness = 1f, DashStyle dashStyle = null)
{
var cache = generator.Cache<PenKey, Pen> (cacheKey);
Pen pen;
lock (cache) {
var key = new PenKey (color.ToArgb (), thickness, dashStyle);
if (!cache.TryGetValue (key, out pen)) {
pen = new Pen (color, thickness, generator);
if (dashStyle != null) pen.DashStyle = dashStyle;
cache.Add (key, pen);
}
}
return pen;
}
示例8: GetFont
static Font GetFont(SystemFont systemFont, float? size, FontDecoration decoration, Generator generator)
{
var cache = generator.Cache<FontCacheKey, Font>(cacheKey);
Font font;
lock (cache)
{
var key = new FontCacheKey(systemFont, size, decoration);
if (!cache.TryGetValue(key, out font))
{
font = new Font(systemFont, size, decoration, generator);
cache.Add(key, font);
}
}
return font;
}
示例9: ClearCache
public static void ClearCache (Generator generator)
{
var cache = generator.Cache<FontCacheKey, Font>(cacheKey);
lock (cache) {
cache.Clear ();
}
}