public List <SecurityGroupIngress> AddIngress(SecurityGroup securityGroup, Protocol protocol, Ports fromPort, Ports toPort)
        {
            List <SecurityGroupIngress> returnValue = new List <SecurityGroupIngress>();

            var protocols = GetProtocolsListFromFlaggedValue(protocol);

            foreach (var thisProtocol in protocols)
            {
                SecurityGroupIngress newIngressEgress;

                if (((int)toPort) == 0)
                {
                    toPort = fromPort;
                }

                newIngressEgress = new SecurityGroupIngress((int)fromPort, (int)toPort, thisProtocol.ToLower(), securityGroup) as SecurityGroupIngress;
                List <SecurityGroupIngress> temp = new List <SecurityGroupIngress>();
                this.SecurityGroupIngress.Add(newIngressEgress);
                //temp.AddRange(this.SecurityGroupIngress);
                //temp.Add(newIngressEgress);
                //this.SecurityGroupIngress = temp.ToArray();

                returnValue.Add(newIngressEgress);
            }


            return(returnValue);
        }
        private SecurityGroupIngress AddIngress(string cidr, string protocol, int fromPort, int toPort)
        {
            SecurityGroupIngress newIngressEgress;

            newIngressEgress = new SecurityGroupIngress(fromPort, toPort, protocol.ToString().ToLower(), cidr) as SecurityGroupIngress;
            //List<SecurityGroupIngress> temp = new List<SecurityGroupIngress>();
            //temp.AddRange(this.SecurityGroupIngress.Cast<SecurityGroupIngress>());
            //temp.Add(new SecurityGroupIngress(fromPort,toPort,protocol,cidr));
            //SecurityGroupIngress[] myArray = temp.ToArray();
            //this.SecurityGroupIngress = myArray;
            this.SecurityGroupIngress.Add(newIngressEgress);
            return(newIngressEgress);
        }
        public SecurityGroupIngress AddIngress(ILogicalId logicalId, Protocol protocol, Ports port)
        {
            SecurityGroupIngress newIngressEgress;

            newIngressEgress = new SecurityGroupIngress(logicalId, protocol, port);
            //List<SecurityGroupIngress> temp = new List<SecurityGroupIngress>();
            //temp.AddRange(this.SecurityGroupIngress.Cast<SecurityGroupIngress>());
            //temp.Add(newIngressEgress);
            //SecurityGroupIngress[] myArray = temp.ToArray();
            //this.SecurityGroupIngress = myArray;
            this.SecurityGroupIngress.Add(newIngressEgress);
            return(newIngressEgress);
        }