コード例 #1
0
        /// <summary>
        /// Loads XML from the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static SerializedXMLFile Load(String path)
        {
            if (!File.Exists(path))
            {
                return(null);
            }

            SerializedXMLFile output = new SerializedXMLFile();

            output.fileInfo = new FileInfo(path);

            output.source = File.ReadAllText(path);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(output.source);

            String tname = doc.Name;

            if (tname.StartsWith("ArrayOf"))
            {
                output.IsArrayOf = true;
                tname            = tname.Substring("ArrayOf".Length);
            }

            output.typename = tname;
            return(output);
        }
コード例 #2
0
        /// <summary>
        /// Registers the specified x file.
        /// </summary>
        /// <param name="xFile">The x file.</param>
        public void Register(SerializedXMLFile xFile)
        {
            if (xFile == null)
            {
                return;
            }
            if (xFile.typename.isNullOrEmpty())
            {
                return;
            }

            if (!filesByType.ContainsKey(xFile.typename))
            {
                filesByType.Add(xFile.typename, new List <SerializedXMLFile>());
            }
            filesByType[xFile.typename].Add(xFile);
        }
コード例 #3
0
        /// <summary>
        /// Scans the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <returns></returns>
        public static SerializedXMLFileDictionary ScanFolder(folderNode folder, String customSearch = "*.xml")
        {
            SerializedXMLFileDictionary output = new SerializedXMLFileDictionary();

            output.folder = folder;

            List <String> files = folder.findFiles(customSearch, SearchOption.AllDirectories);

            foreach (String f in files)
            {
                SerializedXMLFile xFile = SerializedXMLFile.Load(f);

                output.Register(xFile);
            }

            return(output);
        }