Exemplo n.º 1
0
Arquivo: xml.cs Projeto: Sciumo/gaigen
        private static void ParseRootElement(Specification S, XmlElement rootElement)
        {
            ParseRootElementAttributes(S, rootElement.Attributes);

            XmlNode _E = rootElement.FirstChild;
            while (_E != null)
            {
                XmlElement E = _E as XmlElement;
                if (E != null)
                {
                    switch (E.Name)
                    {
                        case XML_CUSTOM_LICENSE:
                            {
                                if (S.m_license != XML_CUSTOM)
                                    throw new G25.UserException("License was not set to '" + XML_CUSTOM + "' but there still is a '" + XML_CUSTOM_LICENSE + "' in the specification");
                                XmlText T = E.FirstChild as XmlText;
                                if (T != null)
                                    S.m_license = T.Value;
                            }
                            break;
                        case XML_OUTPUT_DIRECTORY:
                            S.SetOutputDir(E.GetAttribute(XML_PATH));
                            break;
                        case XML_OUTPUT_FILENAME:
                            S.SetOutputFilename(E.GetAttribute(XML_DEFAULT_NAME), E.GetAttribute(XML_CUSTOM_NAME));
                            break;

                        case XML_INLINE:
                            ParseInlineAttributes(S, E.Attributes);
                            break;
                        case XML_FLOAT_TYPE:
                            ParseFloatTypeAttributes(S, E.Attributes);
                            break;
                        case XML_UNARY_OPERATOR:
                        case XML_BINARY_OPERATOR:
                            ParseOperatorAttributes(S, E.Name, E.Attributes);
                            break;
                        case XML_BASIS_VECTOR_NAMES:
                            ParseBasisVectorNamesAttributes(S, E.Attributes);
                            break;
                        case XML_METRIC:
                            {
                                // name
                                string name = E.GetAttribute(XML_NAME);
                                if (name == null) name = "default";

                                // parse actual metric:
                                XmlText T = E.FirstChild as XmlText;
                                if (T == null) throw new G25.UserException("Invalid  '" + XML_METRIC + "' element in specification.");
                                ParseMetric(S, name, T.Value);

                                // round?
                                if (E.GetAttribute(XML_ROUND) != null)
                                {
                                    S.GetMetric(name).m_round = !(E.GetAttribute(XML_ROUND).ToLower() == XML_FALSE);
                                }

                            }
                            break;
                        case XML_MV:
                            ParseMVelementAndAttributes(S, E);
                            break;
                        case XML_SMV:
                            ParseSMVelementAndAttributes(S, E);
                            break;
                        case XML_OM:
                            ParseGOMelementAndAttributes(S, E);
                            break;
                        case XML_SOM:
                            ParseSOMelementAndAttributes(S, E);
                            break;
                        case XML_CONSTANT:
                            ParseConstantElementAndAttributes(S, E);
                            break;
                        case XML_FUNCTION:
                            ParseFunction(S, E);
                            break;
                        case XML_VERBATIM:
                            ParseVerbatim(S, E);
                            break;
                        default:
                            System.Console.WriteLine("Specification.ParseRootElement(): warning: unknown element '" + E.Name + "' in specification");
                            break;
                    }
                }

                _E = _E.NextSibling;
            }
        }