public static ContainerAnyUnits CreateAnyContainer(this BaseContainerUnits container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            return(new ContainerAnyUnits());
        }
        public static ContainerAnyUnits CreateAnyContainer(this BaseContainerUnits container, int aliveCount, params Unit[] units)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var newContainer = new ContainerAnyUnits();

            return(newContainer.Add(aliveCount, units));
        }
        public static ContainerListUnits CreateListContainer(this BaseContainerUnits container, params Unit[] units)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var newContainer = new ContainerListUnits();

            return(newContainer.Add(units));
        }
        private static BaseContainerUnits _If(this BaseContainerUnits container, bool any, params Unit[] units)
        {
            var containerIfElsesUnits = container.LastAddedUnit as ContainerIfElsesUnits;

            if (containerIfElsesUnits == null)
            {
                containerIfElsesUnits = new ContainerIfElsesUnits();
                container.AddUnit(containerIfElsesUnits);
            }
            else
            {
                BaseContainerUnits ownerContainerIfElseUnits = containerIfElsesUnits;
                var nextContainer = containerIfElsesUnits;

                while (nextContainer != null)
                {
                    var lastAddedContainer = nextContainer.LastAddedUnit;
                    var containerListUnits = lastAddedContainer as ContainerListUnits;
                    if (containerListUnits != null)
                    {
                        ownerContainerIfElseUnits = containerListUnits;
                        nextContainer             = ownerContainerIfElseUnits.LastAddedUnit as ContainerIfElsesUnits;
                    }
                    else
                    {
                        if (lastAddedContainer != null)
                        {
                            throw new InvalidOperationException();
                        }
                    }
                }

                containerIfElsesUnits = new ContainerIfElsesUnits();
                ownerContainerIfElseUnits.AddUnit(containerIfElsesUnits);
            }

            var newContainer = any ? new ContainerAnyUnits() : (BaseContainerUnits)(new ContainerListUnits());

            foreach (var unit in units)
            {
                newContainer.AddUnit(unit);
            }

            containerIfElsesUnits.AddUnit(newContainer);

            return(newContainer);
        }
 public static ContainerAnyUnits CreateAnyContainer(this BaseContainerUnits container, params Unit[] units)
 {
     return(container.CreateAnyContainer(1, units));
 }