当前位置: 首页>>代码示例>>C#>>正文


C# ILogger.?.Debug方法代码示例

本文整理汇总了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.");
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:14,代码来源:SyncedItemPostProcessor.cs

示例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");
        }
开发者ID:Eldblom,项目名称:Unicorn,代码行数:19,代码来源:SyncedItemPostProcessor.cs

示例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;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:81,代码来源:TextureTool.cs


注:本文中的ILogger.?.Debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。