小编JS *_*uru的帖子

如何在 Angular 库中添加和安装对等依赖项

现在我正在构建 Angular 库来定义可重用组件。我制作了一个名为 main-layout 的组件。我需要在组件中使用 ngx-perfect-scrollbar 。我知道如何在 Angular 项目中添加依赖项。

ng add [package name]
Run Code Online (Sandbox Code Playgroud)

或者

npm install [package name]
Run Code Online (Sandbox Code Playgroud)

但我看到一篇文章说对等依赖项是手动添加的。所以我在我正在开发的库的package.json上的peerDependency中添加了ngx-perfect-scrollbar。

在此输入图像描述

之后,我尝试在项目的根目录中安装 npm 包。

npm install
Run Code Online (Sandbox Code Playgroud)

然后我注意到 ngx-perfect-scrollbar 包没有安装在 node_modules 中。

以下是我的角度库项目的完整结构。

在此输入图像描述

npm angular angular-library

15
推荐指数
1
解决办法
2万
查看次数

如何获取当前使用的网络适配器

现在我正在尝试在我的机器上的多个网络适配器之间获取正在使用的网络适配器,以便我可以获得网络适配器的ip地址、mac地址和适配器名称。但我没有任何运气。我找到的解决方案是获取当前使用的网络适配器。我不认为它适用于 .Net 框架项目,而是适用于 ASP.NET Core。

我的代码如下。

public void GetIpAndMacAddress()
{
    foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
    {
        // Only consider Ethernet network interfaces
        if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet &&
            nic.OperationalStatus == OperationalStatus.Up)
        {
            IPInterfaceProperties adapterProperties = nic.GetIPProperties();
            foreach (var ip in adapterProperties.UnicastAddresses) 
            {
                if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    IPAddress = ip.Address.ToString();
            }
            string hexMac = nic.GetPhysicalAddress().ToString(),
                   regex = "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})",
                   replace = "$1:$2:$3:$4:$5:$6";
            IPv4InterfaceProperties p = adapterProperties.GetIPv4Properties();

            netAdapterName = nic.Name;
            MACAddress = Regex.Replace(hexMac, regex, replace);
            return;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# mac-address ip-address

4
推荐指数
1
解决办法
3712
查看次数

标签 统计

angular ×1

angular-library ×1

c# ×1

ip-address ×1

mac-address ×1

npm ×1