コード例 #1
0
    public void imethod_0(HashSet <string> hashSet_0 = null)
    {
        ManagementScope scope = new ManagementScope("\\\\" + Environment.MachineName + "\\root\\standardcimv2");

        new ManagementClass(scope, new ManagementPath("MSFT_NetIPAddress"), new ObjectGetOptions());
        foreach (ManagementBaseObject managementBaseObject in new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM MSFT_NetIPAddress")).Get())
        {
            ManagementObject managementObject = (ManagementObject)managementBaseObject;
            string           item             = GClass885.smethod_0 <string>(managementObject, "IPAddress");
            if ((long)NetworkInterface.LoopbackInterfaceIndex == (long)((ulong)GClass885.smethod_0 <uint>(managementObject, "InterfaceIndex")) & (GClass885.smethod_1(GClass885.smethod_0 <string>(managementObject, "PreferredLifetime"), TimeSpan.FromHours(24.0)) && (hashSet_0 == null || hashSet_0.Contains(item))))
            {
                managementObject.Delete();
            }
        }
    }
コード例 #2
0
    public void imethod_1(string[] string_0)
    {
        HashSet <string> hashSet         = new HashSet <string>(string_0);
        ManagementScope  scope           = new ManagementScope("\\\\" + Environment.MachineName + "\\root\\standardcimv2");
        ManagementClass  managementClass = new ManagementClass(scope, new ManagementPath("MSFT_NetIPAddress"), new ObjectGetOptions());

        foreach (ManagementBaseObject managementBaseObject in new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM MSFT_NetIPAddress")).Get())
        {
            string item = GClass885.smethod_0 <string>((ManagementObject)managementBaseObject, "IPAddress");
            hashSet.Remove(item);
        }
        ManagementBaseObject methodParameters = managementClass.GetMethodParameters("Create");

        methodParameters["InterfaceIndex"]    = NetworkInterface.LoopbackInterfaceIndex;
        methodParameters["PreferredLifetime"] = ManagementDateTimeConverter.ToDmtfTimeInterval(TimeSpan.FromHours(24.0));
        foreach (string value in hashSet)
        {
            methodParameters["IPAddress"] = value;
            managementClass.InvokeMethod("Create", methodParameters, null);
        }
    }