public static PSIpRule Create(CognitiveServicesModels.IpRule ipRule) { var result = new PSIpRule(); result.IpAddress = ipRule.Value; return(result); }
public void AddIpRule(string ipAddress) { if (this.IpRules == null) { IpRules = new PSIpRule[] { new PSIpRule() { IpAddress = ipAddress } }; } else { var tmp = new List <PSIpRule>(IpRules); tmp.Add(new PSIpRule() { IpAddress = ipAddress }); IpRules = tmp.ToArray(); } }
public static PSNetworkRuleSet Create(CognitiveServicesModels.NetworkRuleSet networkRuleSet) { var result = new PSNetworkRuleSet(); if (networkRuleSet.DefaultAction != null) { result.DefaultAction = (PSNetWorkRuleDefaultActionEnum)Enum.Parse(typeof(PSNetWorkRuleDefaultActionEnum), networkRuleSet.DefaultAction); } else { result.DefaultAction = PSNetWorkRuleDefaultActionEnum.Deny; } var ipRules = new List <PSIpRule>(); if (networkRuleSet.IpRules != null) { foreach (var ipRule in networkRuleSet.IpRules) { ipRules.Add(PSIpRule.Create(ipRule)); } } result.IpRules = ipRules.ToArray(); var virtualNetworkRules = new List <PSVirtualNetworkRule>(); if (networkRuleSet.VirtualNetworkRules != null) { foreach (var virtualNetworkRule in networkRuleSet.VirtualNetworkRules) { virtualNetworkRules.Add(PSVirtualNetworkRule.Create(virtualNetworkRule)); } } result.VirtualNetworkRules = virtualNetworkRules.ToArray(); return(result); }