本文整理汇总了C#中ILogger.?.Debug方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.?.Debug方法的具体用法?C# ILogger.?.Debug怎么用?C# ILogger.?.Debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.?.Debug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSearchIndexes
protected virtual void UpdateSearchIndexes(Item[] items, ILogger logger)
{
logger?.Info("");
logger?.Info("[I] Updating search indexes for changed items.");
foreach (var index in ContentSearchManager.Indexes)
{
var changes = items.Select(change => new SitecoreItemUniqueId(change.Uri));
IndexCustodian.IncrementalUpdate(index, changes);
}
logger?.Debug($"> Queued updates for {items.Length} items in the search indexes. Will run async.");
}
示例2: UpdateLinkDatabase
protected virtual void UpdateLinkDatabase(Item[] items, ILogger logger)
{
logger?.Info("");
logger?.Info("[L] Updating link database for changed items.");
Stopwatch sw = new Stopwatch();
sw.Start();
foreach (var item in items)
{
Globals.LinkDatabase.UpdateReferences(item);
// NOTE: we don't have a reference to deleted items. This means that due to the link DB API requiring an Item parameter, we can't really remove deleted items from the LDB.
}
sw.Stop();
logger?.Debug($"> Updated {items.Length} items in the link database in {(sw.ElapsedMilliseconds / 1000):F2} sec");
}
示例3: GetAlphaLevels
/// <summary>
/// Gets the alpha levels of the image in the provided region.
/// </summary>
/// <param name="texture">The texture</param>
/// <param name="region">The region of the texture to analyze</param>
/// <param name="tranparencyColor">The color used as transparent color. If null use standard alpha channel.</param>
/// <param name="logger">The logger used to log information</param>
/// <returns></returns>
public unsafe AlphaLevels GetAlphaLevels(TexImage texture, Rectangle region, Color? tranparencyColor, ILogger logger = null)
{
// quick escape when it is possible to know the absence of alpha from the file itself
var alphaDepth = texture.GetAlphaDepth();
if(!tranparencyColor.HasValue && alphaDepth == 0)
return AlphaLevels.NoAlpha;
// check that we support the format
var format = texture.Format;
var pixelSize = format.SizeInBytes();
if (texture.Dimension != TexImage.TextureDimension.Texture2D || !(format.IsRGBAOrder() || format.IsBGRAOrder() || pixelSize != 4))
{
var guessedAlphaLevel = alphaDepth > 0 ? AlphaLevels.InterpolatedAlpha : AlphaLevels.NoAlpha;
logger?.Debug("Impossible to find alpha levels for texture type {0}. Returning default alpha level '{1}'.", format, guessedAlphaLevel);
return guessedAlphaLevel;
}
// truncate the provided region in order to be sure to be in the texture
region.Width = Math.Min(region.Width, texture.Width - region.Left);
region.Height = Math.Min(region.Height, texture.Height- region.Top);
var alphaLevel = AlphaLevels.NoAlpha;
var stride = texture.RowPitch;
var startPtr = (byte*)texture.Data + stride * region.Y + pixelSize * region.X;
var rowPtr = startPtr;
if (tranparencyColor.HasValue) // specific case when using a transparency color
{
var transparencyValue = format.IsRGBAOrder() ? tranparencyColor.Value.ToRgba() : tranparencyColor.Value.ToBgra();
for (int y = 0; y < region.Height; ++y)
{
var ptr = (int*)rowPtr;
for (int x = 0; x < region.Width; x++)
{
if (*ptr == transparencyValue)
return AlphaLevels.MaskAlpha;
ptr += 1;
}
rowPtr += stride;
}
}
else // use default alpha channel
{
for (int y = 0; y < region.Height; ++y)
{
var ptr = rowPtr+3;
for (int x = 0; x < region.Width; x++)
{
var value = *ptr;
if (value == 0)
{
if (alphaDepth == 1)
return AlphaLevels.MaskAlpha;
alphaLevel = AlphaLevels.MaskAlpha;
}
else if (value != 0xff)
{
return AlphaLevels.InterpolatedAlpha;
}
ptr += 4;
}
rowPtr += stride;
}
}
return alphaLevel;
}