public void AddNetworkRules(IList <IPSNetworkRule> networkRules) { if (networkRules == null) { return; } VirtualNetworkRules = VirtualNetworkRules ?? new List <PSVirtualNetworkRule>(); IpRules = IpRules ?? new List <PSIPRule>(); foreach (IPSNetworkRule rule in networkRules) { switch (rule.NetworkRuleType) { case "VirtualNetworkRule": VirtualNetworkRules.Add((PSVirtualNetworkRule)rule); break; case "IPRule": IpRules.Add((PSIPRule)rule); break; default: throw new PSArgumentException("Invalid network rule type"); } } }
public NetworkRuleSet GetNetworkRuleSet() { return(new NetworkRuleSet { DefaultAction = DefaultAction, VirtualNetworkRules = VirtualNetworkRules?.Select(x => x.GetVirtualNetworkRule()).ToList(), IpRules = IpRules?.Select(x => x.GetIPRule()).ToList() }); }