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


C# IConsole.WriteWarning方法代码示例

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


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

示例1: RepositoryAssemblyResolver

        /// <summary>
        /// Initializes a new instance of the <see cref="RepositoryAssemblyResolver"/> class.
        /// </summary>
        /// <param name="assemblies">The assemblies to look for.</param>
        /// <param name="packageSource">The package sources to search.</param>
        /// <param name="fileSystem">The file system to output any packages.config files.</param>
        /// <param name="console">The console to output to.</param>
        public RepositoryAssemblyResolver(List<string> assemblies, IQueryable<IPackage> packageSource, IFileSystem fileSystem, IConsole console)
        {
            _packageSource = packageSource;
            _fileSystem = fileSystem;
            _console = console;

            foreach (var assembly in assemblies.Where(assembly => !_assemblies.Add(assembly)))
            {
                console.WriteWarning("Same assembly resolution will be used for both assembly references to {0}", assembly);
            }
            _resolvedAssemblies = _assemblies.ToDictionary(a => a, _ => new List<IPackage>());
        }
开发者ID:modulexcite,项目名称:NuGet.Extensions,代码行数:19,代码来源:RepositoryAssemblyResolver.cs

示例2: RegisterExtensions

 private static void RegisterExtensions(AggregateCatalog catalog, IEnumerable<string> enumerateFiles, IConsole console)
 {
     foreach (var item in enumerateFiles)
     {
         try
         {
             catalog.Catalogs.Add(new AssemblyCatalog(item));
         }
         catch (BadImageFormatException ex)
         {
             // Ignore if the dll wasn't a valid assembly
             console.WriteWarning(ex.Message);
         }
         catch (FileLoadException ex)
         {
             // Ignore if we couldn't load the assembly.
             console.WriteWarning(ex.Message);
         }
     }
 }
开发者ID:nickfloyd,项目名称:NuGet,代码行数:20,代码来源:Program.cs

示例3: RegisterExtensions

        private static void RegisterExtensions(AggregateCatalog catalog, IEnumerable<string> enumerateFiles, IConsole console)
        {
            foreach (var item in enumerateFiles)
            {
                AssemblyCatalog assemblyCatalog = null;
                try
                {
                    assemblyCatalog = new AssemblyCatalog(item);

                    // get the parts - throw if something went wrong
                    var parts = assemblyCatalog.Parts;

                    // load all the types - throw if assembly cannot load (missing dependencies is a good example)
                    var assembly = Assembly.LoadFile(item);
                    assembly.GetTypes();

                    catalog.Catalogs.Add(assemblyCatalog);
                }
                catch (BadImageFormatException ex)
                {
                    if (assemblyCatalog != null)
                    {
                        assemblyCatalog.Dispose();
                    }

                    // Ignore if the dll wasn't a valid assembly
                    console.WriteWarning(ex.Message);
                }
                catch (FileLoadException ex)
                {
                    // Ignore if we couldn't load the assembly.

                    if (assemblyCatalog != null)
                    {
                        assemblyCatalog.Dispose();
                    }

                    var message =
                        String.Format(LocalizedResourceManager.GetString(nameof(NuGetResources.FailedToLoadExtension)),
                                      item);

                    console.WriteWarning(message);
                    console.WriteWarning(ex.Message);
                }
                catch (ReflectionTypeLoadException rex)
                {
                    // ignore if the assembly is missing dependencies

                    var resource =
                        LocalizedResourceManager.GetString(nameof(NuGetResources.FailedToLoadExtensionDuringMefComposition));

                    var perAssemblyError = string.Empty;

                    if (rex?.LoaderExceptions.Length > 0)
                    {
                        var builder = new StringBuilder();

                        builder.AppendLine(string.Empty);

                        var errors = rex.LoaderExceptions.Select(e => e.Message).Distinct(StringComparer.Ordinal);

                        foreach (var error in errors)
                        {
                            builder.AppendLine(error);
                        }

                        perAssemblyError = builder.ToString();
                    }

                    var warning = string.Format(resource, item, perAssemblyError);

                    console.WriteWarning(warning);
                }
            }
        }
开发者ID:danni95,项目名称:Core,代码行数:75,代码来源:Program.cs


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