コード例 #1
0
        public bool Load(XmlElement el, FDMExecutive fdmex, string prefix = "")
        {
            LocalProperties.Load(el, fdmex.PropertyManager, false);
            PreLoad(el, fdmex, prefix);

            return(true); // TODO: Need to make this value mean something.
        }
コード例 #2
0
        /// <summary>
        /// Loads this model.
        /// </summary>
        /// <param name="el"></param>
        /// <param name="preLoad">true if model functions and local properties must be
        /// preloaded.</param>
        /// <returns>true if model is successfully loaded</returns>
        protected virtual bool Load(XmlElement el, bool preLoad)
        {
            ModelLoader    modelLoader    = new ModelLoader(this);
            XmlElement     document       = modelLoader.Open(el);
            ModelFunctions ModelFunctions = new ModelFunctions();

            if (document == null)
            {
                return(false);
            }

            if (document.Name != el.Name)
            {
                log.Error(" Read model '" + document.Name
                          + "' while expecting model '" + el.Name + "'");
                return(false);
            }

            bool result = true;

            if (preLoad)
            {
                result = ModelFunctions.Load(document, FDMExec);
            }

            if (document != el)
            {
                el.MergeAttributes(document);

                if (preLoad)
                {
                    // After reading interface properties in a file, read properties in the
                    // local model element. This allows general-purpose models to be defined
                    // in a file, with overrides or initial loaded constants supplied in the
                    // relevant element of the aircraft configuration file.
                    LocalProperties.Load(el, propertyManager, true);
                }

                foreach (var node in document.ChildNodes)
                {
                    XmlElement element = node as XmlElement;
                    if (element != null)
                    {
                        el.AppendChild(element);
                    }
                }
            }

            return(result);
        }