CrabtreeOn,印度客户定制APP,迁移2.0平台版本
JLChen
2022-01-12 407fae6f07a2a982a2a814c2f145c40733c966cb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
using System.Net.Sockets;
using System.Net.NetworkInformation;
 
namespace Shared
{
[System.Serializable]
    public static class Global
    {
        /// <summary>
        /// ����������
        /// </summary>
        public static readonly byte LocalSubnetID = 0;
        /// <summary>
        /// �����豸��
        /// </summary>
        public static readonly byte LocalDeviceID = 252;
        /// <summary>
        /// �����豸����
        /// </summary>
        public static readonly int DeviceType = 0xFFFC;
 
        /// <summary>
        /// ��ȡ��ǰwifi��IP��ַ
        /// </summary>
        /// <returns></returns>
        public static string IpAddress
        {
            get
            {
                foreach (var networkInterface in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
                {
                    foreach (var unicastAddresses in networkInterface.GetIPProperties().UnicastAddresses)
                    {
                        if (unicastAddresses.Address.AddressFamily == AddressFamily.InterNetwork && unicastAddresses.Address.ToString() != "127.0.0.1")
                        {
                            return unicastAddresses.Address.ToString();
                        }
                    }
                }
                return "127.0.0.1";
            }
        }
    }
}