Example #1
0
        /// <summary>
        /// The load routine for the static data file collection
        /// </summary>
        /// <param name="PopulateNodeTrees"></param>
        /// <returns></returns>
        public new bool Load(int PopulateNodeTreeDepth = 0)
        {
            // Loads the static data and builds the trees representing the data files
            if (!DataDirectoryInfo.Exists)
            {
                return(false);
            }
            else
            {
                foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension)) // .Reverse())
                {
                    Debug.Print("File evaluated {0}", dataFile.Name);

                    // Create a new HEStationonBlueprintFile and populate the path.
                    StationBlueprint_File tempBlueprintFile = new StationBlueprint_File(this, dataFile);
                    // Add the file to the Data Dictionary
                    DataDictionary.Add(dataFile.Name, tempBlueprintFile);

                    if (tempBlueprintFile.IsLoaded && !LoadError)
                    {
                        // if (PopulateNodeTreeDepth > 0) tempBlueprintFile.DataViewRootNode.CreateChildNodesFromjData(PopulateNodeTreeDepth);

                        if (tempBlueprintFile.RootNode == null)
                        {
                            throw new NullReferenceException();
                        }
                        else
                        {
                            RootNode.Nodes.Insert(0, tempBlueprintFile.RootNode);
                        }
                    }
                }
                return(true);
            }
        }
        /// <summary>
        /// The load routine for the static data file collection
        /// </summary>
        /// <param name="PopulateNodeTrees"></param>
        /// <returns></returns>
        public bool Load(int populateDepth = 0)
        {
            // Loads the static data and builds the trees representing the data files
            if (!DataDirectoryInfo.Exists)
            {
                return(false);
            }
            else
            {
                foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension))
                {
                    // Create a new Json_File_UI and populate the path.
                    Json_File_UI tempJsonFile = new Json_File_UI(this, dataFile, populateDepth);
                    // Add the file to the Data Dictionary
                    DataDictionary.Add(dataFile.Name, tempJsonFile);

                    //if (tempJsonFile.IsLoaded) // && !LoadError)
                    {
                        if (tempJsonFile.RootNode == null)
                        {
                            throw new NullReferenceException
                                      ("Json_FileCollection.Load: tempJsonFile.RootNode was null.");
                        }
                        else
                        {
                            RootNode.Nodes.Insert(0, tempJsonFile.RootNode);
                        }
                    }
                }
                return(true);
            }
        }