Пример #1
0
        public static IDictionary <string, CameraMetaItem> LoadMeta(string ConfigPath)
        {
            string xml = "";
            IDictionary <string, CameraMetaItem> cameraInfoDict = null;

            using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    xml = streamReader.ReadToEnd();
                }
            }

            CameraMeta cameraMeta = Utility.XmlDeserialize <CameraMeta>(xml, new Type[] { typeof(CameraMetaItem), typeof(List <CameraMetaItem>) }, "utf-8");

            if (cameraMeta != null && cameraMeta.MetaItems != null)
            {
                cameraInfoDict = new Dictionary <string, CameraMetaItem>();

                foreach (var item in cameraMeta.MetaItems)
                {
                    cameraInfoDict.Add(item.Name, item);
                }
            }

            return(cameraInfoDict);
        }
Пример #2
0
        public static void SaveMeta(CameraMeta Meta, string ConfigPath)
        {
            string xml = Utility.XmlSerialize(Meta, null, "utf-8");

            using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    streamWriter.Write(xml);
                }
            }
        }