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


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

本文整理汇总了C#中ILogger.?.Error方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.?.Error方法的具体用法?C# ILogger.?.Error怎么用?C# ILogger.?.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILogger的用法示例。


在下文中一共展示了ILogger.?.Error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveType

        public static Type ResolveType(string fullTypeName, Type expectedBase = null, ILogger logger = null) {
            if (String.IsNullOrEmpty(fullTypeName))
                return null;
            
            var type = Type.GetType(fullTypeName);
            if (type == null) {
                logger?.Error("Unable to resolve type: \"{0}\".", fullTypeName);
                return null;
            }

            if (expectedBase != null && !expectedBase.IsAssignableFrom(type)) {
                logger?.Error("Type \"{0}\" must be assignable to type: \"{1}\".", fullTypeName, expectedBase.FullName);
                return null;
            }

            return type;
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:17,代码来源:TypeHelper.cs

示例2: FindBestTextureSize

        /// <summary>
        /// Utility function to check that the texture size is supported on the graphics platform for the provided graphics profile.
        /// </summary>
        /// <param name="parameters">The import parameters</param>
        /// <param name="textureSizeRequested">The texture size requested.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>true if the texture size is supported</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">graphicsProfile</exception>
        public static Size2 FindBestTextureSize(ImportParameters parameters, Size2 textureSizeRequested, ILogger logger = null)
        {
            var textureSize = textureSizeRequested;

            // compressed DDS files has to have a size multiple of 4.
            if (parameters.GraphicsPlatform == GraphicsPlatform.Direct3D11 && parameters.DesiredFormat == TextureFormat.Compressed
                && ((textureSizeRequested.Width % 4) != 0 || (textureSizeRequested.Height % 4) != 0))
            {
                textureSize.Width = unchecked((int)(((uint)(textureSizeRequested.Width + 3)) & ~(uint)3));
                textureSize.Height = unchecked((int)(((uint)(textureSizeRequested.Height + 3)) & ~(uint)3));
            }

            var maxTextureSize = 0;

            // determine if the desired size if valid depending on the graphics profile
            switch (parameters.GraphicsProfile)
            {
                case GraphicsProfile.Level_9_1:
                case GraphicsProfile.Level_9_2:
                case GraphicsProfile.Level_9_3:
                    if (parameters.GenerateMipmaps && (!MathUtil.IsPow2(textureSize.Width) || !MathUtil.IsPow2(textureSize.Height)))
                    {
                        // TODO: TEMPORARY SETUP A MAX TEXTURE OF 1024. THIS SHOULD BE SPECIFIED DONE IN THE ASSET INSTEAD
                        textureSize.Width = Math.Min(MathUtil.NextPowerOfTwo(textureSize.Width), 1024);
                        textureSize.Height = Math.Min(MathUtil.NextPowerOfTwo(textureSize.Height), 1024);
                        logger?.Warning("Graphic profiles 9.1/9.2/9.3 do not support mipmaps with textures that are not power of 2. Asset is automatically resized to " + textureSize);
                    }
                    maxTextureSize = parameters.GraphicsProfile >= GraphicsProfile.Level_9_3 ? 4096 : 2048;
                    break;
                case GraphicsProfile.Level_10_0:
                case GraphicsProfile.Level_10_1:
                    maxTextureSize = 8192;
                    break;
                case GraphicsProfile.Level_11_0:
                case GraphicsProfile.Level_11_1:
                case GraphicsProfile.Level_11_2:
                    maxTextureSize = 16384;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("graphicsProfile");
            }

            if (textureSize.Width > maxTextureSize || textureSize.Height > maxTextureSize)
            {
                logger?.Error("Graphic profile {0} do not support texture with resolution {2} x {3} because it is larger than {1}. " +
                             "Please reduce texture size or upgrade your graphic profile.", parameters.GraphicsProfile, maxTextureSize, textureSize.Width, textureSize.Height);
                return new Size2(Math.Min(textureSize.Width, maxTextureSize), Math.Min(textureSize.Height, maxTextureSize));
            }

            return textureSize;
        }
开发者ID:releed,项目名称:paradox,代码行数:59,代码来源:TextureHelper.cs

示例3: SetNotActiveAsync

        public static async Task<bool> SetNotActiveAsync(this IFileStorage storage, string path, ILogger logger = null) {
            try {
                return await storage.DeleteFileAsync(path + ".x");
            } catch (Exception ex) {
                logger?.Error(ex, () => $"Error deleting work marker \"{path}.x\": {ex.Message}");
            }

            return false;
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:9,代码来源:FileStorageTestsBase.cs

示例4: CompleteEventPost

        public static async Task<bool> CompleteEventPost(this IFileStorage storage, string path, string projectId, DateTime created, bool shouldArchive = true, ILogger logger = null) {
            // don't move files that are already in the archive
            if (path.StartsWith("archive"))
                return true;

            string archivePath = $"archive\\{projectId}\\{created.ToString("yy\\\\MM\\\\dd")}\\{Path.GetFileName(path)}";

            try {
                if (shouldArchive) {
                    if (!await storage.RenameFileAsync(path, archivePath))
                        return false;
                } else {
                    if (!await storage.DeleteFileAsync(path))
                        return false;
                }
            } catch (Exception ex) {
                logger?.Error(ex, () => $"Error archiving event post data \"{path}\": {ex.Message}");
                return false;
            }

            await storage.SetNotActiveAsync(path);

            return true;
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:24,代码来源:FileStorageTestsBase.cs

示例5: GetEventPostAndSetActiveAsync

        public static async Task<PostInfo> GetEventPostAndSetActiveAsync(this IFileStorage storage, string path, ILogger logger = null) {
            PostInfo eventPostInfo = null;
            try {
                eventPostInfo = await storage.GetObjectAsync<PostInfo>(path);
                if (eventPostInfo == null)
                    return null;

                if (!await storage.ExistsAsync(path + ".x") && !await storage.SaveFileAsync(path + ".x", String.Empty))
                    return null;
            } catch (Exception ex) {
                logger?.Error(ex, () => $"Error retrieving event post data \"{path}\": {ex.Message}");
                return null;
            }

            return eventPostInfo;
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:16,代码来源:FileStorageTestsBase.cs


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