private void AddSerial(SerialDescriptor descriptor)
        {
            string directoryPath = m_Path + "/" + descriptor.Title;

            Directory.CreateDirectory(directoryPath);

            LocalSerial.SaveDescriptor(directoryPath, descriptor);
        }
Exemple #2
0
        public static void SaveDescriptor(string directoryPath, SerialDescriptor descriptor)
        {
            if (!Directory.Exists(directoryPath))
            {
                throw new ArgumentException("Specified directory does not exist.");
            }

            string descriptorPath = directoryPath + "/" + SerialDescriptorFile;

            File.WriteAllText(descriptorPath, descriptor.ToJson());
        }
Exemple #3
0
        public static LocalSerial LoadFrom(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new ArgumentException("Specified directory does not exist.");
            }

            string serialDescriptorPath = path + "/" + SerialDescriptorFile;

            if (!File.Exists(serialDescriptorPath))
            {
                throw new ArgumentException($"Specified directory does not contain serial descriptor file ({SerialDescriptorFile}).");
            }

            string descriptorText = File.ReadAllText(serialDescriptorPath);

            var descriptor = SerialDescriptor.Parse(descriptorText);

            return(new LocalSerial(descriptor.Title, descriptor.Description, descriptor.Playlist));
        }