Ejemplo n.º 1
0
        private static void FlattenChildren(
            List <TreeTypeChild> fieldsAndChoices, List <Field> fields, bool makeOptional)
        {
            foreach (var fieldOrChoice in fieldsAndChoices)
            {
                switch (fieldOrChoice)
                {
                case Field field:
                    if (makeOptional && !AbstractFileWriter.IsAnyNodeList(field.Type))
                    {
                        field.Optional = true;
                    }

                    fields.Add(field);
                    break;

                case Choice choice:
                    // Children of choices are always optional (since the point is to
                    // chose from one of them and leave out the rest).
                    FlattenChildren(choice.Children, fields, makeOptional: true);
                    break;

                case Sequence sequence:
                    FlattenChildren(sequence.Children, fields, makeOptional || sequence.Optional);
                    break;

                default:
                    throw new InvalidOperationException("Unknown child type.");
                }
            }
        }
Ejemplo n.º 2
0
        void SetFileNameToWrite(AbstractFileWriter _writer)
        {
            OpenFileDialog Dialog = new OpenFileDialog
            {
                Filter            = Properties.Resources.FilesExtensionsFilter
                , CheckFileExists = true
                , Multiselect     = true
            };

            if (Dialog.ShowDialog() == true)
            {
                _writer.SetFileToWrite(Dialog.FileName);
            }
        }