コード例 #1
0
        /// <summary>
        /// Replaces the contents of this instance with contents loaded from a file.
        /// </summary>
        /// <param name="filePath">Absolute path to a file containing a ProgramCollection.</param>
        public void Initialize(string filePath)
        {
            // On Mac, it was found that in release builds, a condition exists in which the
            // jzIntv component's configuration has not been initialized prior to INTV.Core trying
            // to fetch a stock .cfg file. This access attempts to ensure proper order of operations.
            var jzIntvConfiguration = SingleInstanceApplication.Instance.GetConfiguration <INTV.JzIntv.Model.Configuration>();

            if (!Directory.Exists(jzIntvConfiguration.DefaultToolsDirectory))
            {
                throw new FileNotFoundException(Resources.Strings.ToolsDirectoryMissingMessage, jzIntvConfiguration.DefaultToolsDirectory);
            }
            var programs = ProgramCollection.Load(filePath);

            Clear();
            AddNewItemsFromList(programs);
        }
コード例 #2
0
        public static ProgramCollection Load(string filePath)
        {
            var path = string.Intern(filePath);

            lock (path)
            {
                ProgramCollection programs = null;
                if (File.Exists(path))
                {
                    using (var fileStream = FileUtilities.OpenFileStream(path))
                    {
                        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(Program.ProgramCollection));
                        programs = serializer.Deserialize(fileStream) as ProgramCollection;
                    }
                }
                return(programs);
            }
        }