Beispiel #1
0
        /// <summary>
        /// Finds all the objects in the arguments and flattens them to a list.
        /// </summary>
        /// <returns>A list containing the flattened objects.</returns>
        private List <ConfigurationObject> ExtraxtInputObject()
        {
            // Prepare the result
            var result = new List <ConfigurationObject>();

            // Local function to extract objects from an argument
            void Extract(ConstructionArgument argument)
            {
                // Switch based on type
                switch (argument)
                {
                // If we have an object argument
                case ObjectConstructionArgument objectArgument:

                    // We simply add the internal object to the result
                    result.Add(objectArgument.PassedObject);

                    break;

                // If we have a set argument
                case SetConstructionArgument setArgument:

                    // We recursively call this function for its internal arguments
                    setArgument.PassedArguments.ForEach(Extract);

                    break;

                // Unhandled cases
                default:
                    throw new GeoGenException($"Unhandled type of {nameof(ConstructionArgument)}: {argument.GetType()}");
                }
            }

            // Now we just call our local function for all the arguments
            ArgumentsList.ForEach(Extract);

            // And return the result
            return(result);
        }