public Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithAttach <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> ToFluentRule(String ruleName, Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate withCreate)
        {
            this.SetDefaults();

            var next1 = withCreate.DefineRule(ruleName)
                        .AllowInbound();

            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithSourcePort <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> next2;
            if (this.FromAddress != null)
            {
                next2 = next1.FromAddress(this.FromAddress);
            }
            else
            {
                next2 = next1.FromAnyAddress();
            }

            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithDestinationAddress <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> next3;
            if (this.FromPort != null)
            {
                if (this.FromPort == "*")
                {
                    next3 = next2.FromAnyPort();
                }
                else
                {
                    next3 = next2.FromPort(Int32.Parse(this.FromPort));
                }
            }
            else
            {
                next3 = next2.FromAnyPort();
            }

            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithDestinationPort <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> next4;
            if (this.ToAddress != null)
            {
                next4 = next3.ToAddress(this.ToAddress);
            }
            else
            {
                next4 = next3.ToAnyAddress();
            }

            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithProtocol <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> next5;
            if (this.ToPort != null)
            {
                if (this.ToPort == "*")
                {
                    next5 = next4.ToAnyPort();
                }
                else
                {
                    next5 = next4.ToPort(Int32.Parse(this.ToPort));
                }
            }
            else
            {
                next5 = next4.ToAnyPort();
            }

            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithAttach <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> next6;
            if (this.Protocol != null)
            {
                next6 = next5.WithProtocol(this.Protocol);
            }
            else
            {
                next6 = next5.WithAnyProtocol();
            }
            return(next6);
        }
        public Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate ToFluentRule(String ruleName, Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate withCreate)
        {
            Microsoft.Azure.Management.Network.Fluent.NetworkSecurityRule.Definition.IWithAttach <Microsoft.Azure.Management.Network.Fluent.NetworkSecurityGroup.Definition.IWithCreate> withAttach = null;

            if (this.AllowInbound != null)
            {
                withAttach = this.AllowInbound.ToFluentRule(ruleName, withCreate);
            }
            else if (this.AllowOutbound != null)
            {
                withAttach = this.AllowOutbound.ToFluentRule(ruleName, withCreate);
            }
            else if (this.DenyInbound != null)
            {
                withAttach = this.DenyInbound.ToFluentRule(ruleName, withCreate);
            }
            else if (this.DenyOutbound != null)
            {
                withAttach = this.DenyOutbound.ToFluentRule(ruleName, withCreate);
            }
            if (withAttach != null)
            {
                if (this.Priority != null)
                {
                    withAttach.WithPriority(this.Priority.Value);
                }
                if (this.Description != null)
                {
                    withAttach.WithDescription(this.Description);
                }
            }
            return(withAttach.Attach());
        }