using JinianNet.JNTemplate; using System.Net.NetworkInformation; namespace ZR.Admin.WebApi.Extensions { public static class LogoExtension { public static void AddLogo(this IServiceCollection services) { Console.ForegroundColor = ConsoleColor.Blue; var contentTpl = JnHelper.ReadTemplate("", "logo.txt"); var content = contentTpl?.Render(); Console.WriteLine(content); Console.ForegroundColor = ConsoleColor.Blue; // 获取本地计算机的所有网络接口信息 NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface networkInterface in networkInterfaces) { // 过滤出活动的网络接口 if (networkInterface.OperationalStatus == OperationalStatus.Up) { // 获取网络接口的IP属性 IPInterfaceProperties ipProperties = networkInterface.GetIPProperties(); UnicastIPAddressInformationCollection ipAddresses = ipProperties.UnicastAddresses; foreach (UnicastIPAddressInformation ipAddress in ipAddresses) { // 输出IPv4地址 if (ipAddress.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { Console.WriteLine("本机ip: " + ipAddress.Address.ToString()); } } } } } } }