public Profile(string profileName) { FileStream stream = null; Profile profile; string path = Path.Combine(_profileDir, profileName + ".profile"); BinaryFormatter formatter = new BinaryFormatter(); if (!File.Exists(path)) { throw new ProfileNotFoundException("profile文件未找到"); } try { stream = new FileStream(path, FileMode.Open); profile = formatter.Deserialize(stream) as Profile; stream.Close(); } catch (Exception) { stream.Close(); throw new ProfileNotFoundException("profile文件损坏"); } this._avsConfig = profile._avsConfig; this._videoEncConfig = profile._videoEncConfig; this._audioEncConfig = profile._audioEncConfig; this._jobConfig = profile._jobConfig; this._subtitleConfig = profile._subtitleConfig; }
public Profile(bool initializeConfig) { if (initializeConfig) { this._avsConfig = new AvisynthConfig(); this._videoEncConfig = new x264Config(); this._audioEncConfig = new NeroAacConfig(); this._jobConfig = new JobItemConfig(); this._subtitleConfig = new Cxgui.Avisynth.SubtitleConfig(); } }
public static void Save(string profileName, JobItemConfig jobConfig, AvisynthConfig avsConfig, VideoEncConfigBase videoEncConfig, AudioEncConfigBase audioEncConfig, Cxgui.Avisynth.SubtitleConfig subtitleConfig) { BinaryFormatter formatter = new BinaryFormatter(); string path = Path.Combine(_profileDir, profileName + ".profile"); Profile graph = new Profile(false); graph._jobConfig = jobConfig; graph._videoEncConfig = (x264Config)videoEncConfig; graph._audioEncConfig = (NeroAacConfig)audioEncConfig; graph._avsConfig = avsConfig; graph._subtitleConfig = subtitleConfig; FileStream serializationStream = new FileStream(path, FileMode.Create); formatter.Serialize(serializationStream, graph); serializationStream.Close(); }