/// <summary> /// Called from the package class when there are options to be read out of the solution file. /// </summary> /// <param name="Stream">The stream to load the option data from.</param> public void LoadOptions(Stream Stream) { try { _BuildJobSetsCollection.Clear(); using (BinaryReader Reader = new BinaryReader(Stream)) { int SetCount = Reader.ReadInt32(); for (int SetIdx = 0; SetIdx < SetCount; SetIdx++) { BuildJobSet LoadedSet = new BuildJobSet(); LoadedSet.Name = Reader.ReadString(); int JobCount = Reader.ReadInt32(); for (int JobIdx = 0; JobIdx < JobCount; JobIdx++) { Utils.SafeProjectReference ProjectRef = new Utils.SafeProjectReference { FullName = Reader.ReadString(), Name = Reader.ReadString() }; string Config = Reader.ReadString(); string Platform = Reader.ReadString(); BuildJob.BuildJobType JobType; if (Enum.TryParse(Reader.ReadString(), out JobType)) { LoadedSet.BuildJobs.Add(new BuildJob(ProjectRef, Config, Platform, JobType)); } } _BuildJobSetsCollection.Add(LoadedSet); } } if (_BuildJobSetsCollection.Count == 0) { BuildJobSet DefaultItem = new BuildJobSet { Name = "UntitledSet" }; _BuildJobSetsCollection.Add(DefaultItem); } StateLoaded?.Invoke(this, null); } catch (Exception ex) { Exception AppEx = new ApplicationException("BatchBuilder failed to load options from .suo", ex); Logging.WriteLine(AppEx.ToString()); throw AppEx; } }
////////////// private methods /////////////////////// private void EnsureDefaultBuildJobSet() { if (_BuildJobSetsCollection.Count == 0) { BuildJobSet DefaultItem = new BuildJobSet { Name = "UntitledSet" }; _BuildJobSetsCollection.Add(DefaultItem); if (SetCombo != null) { SetCombo.SelectedItem = DefaultItem; } } }
private void OnSetComboSelectionChanged(object sender, SelectionChangedEventArgs e) { if (SetCombo.SelectedItem != null) { _LastSelectedBuildJobSet = (BuildJobSet) SetCombo.SelectedItem; BuildJobs = _LastSelectedBuildJobSet.BuildJobs; IsDeletableSetSelected = _BuildJobSetsCollection.Count > 1; BuildJobsPanelTitle = String.Format("{0} ({1})", BuildJobsPanelPrefix, _LastSelectedBuildJobSet.Name); } if (!_BuildJobSetsCollection.Contains(_LastSelectedBuildJobSet)) { _LastSelectedBuildJobSet = null; BuildJobs = new ObservableCollection<BuildJob>(); IsDeletableSetSelected = false; BuildJobsPanelTitle = BuildJobsPanelPrefix; } }
////////////// private methods /////////////////////// private void EnsureDefaultBuildJobSet() { if (_BuildJobSetsCollection.Count == 0) { BuildJobSet DefaultItem = new BuildJobSet {Name = "UntitledSet"}; _BuildJobSetsCollection.Add(DefaultItem); if (SetCombo != null) { SetCombo.SelectedItem = DefaultItem; } } }
/// <summary> /// Called from the package class when there are options to be read out of the solution file. /// </summary> /// <param name="Stream">The stream to load the option data from.</param> public void LoadOptions(Stream Stream) { _BuildJobSetsCollection.Clear(); using (BinaryReader Reader = new BinaryReader(Stream)) { int SetCount = Reader.ReadInt32(); for (int SetIdx = 0; SetIdx < SetCount; SetIdx++) { BuildJobSet LoadedSet = new BuildJobSet(); LoadedSet.Name = Reader.ReadString(); int JobCount = Reader.ReadInt32(); for (int JobIdx = 0; JobIdx < JobCount; JobIdx++) { Utils.SafeProjectReference ProjectRef = new Utils.SafeProjectReference { FullName = Reader.ReadString(), Name = Reader.ReadString() }; string Config = Reader.ReadString(); string Platform = Reader.ReadString(); BuildJob.BuildJobType JobType; if (Enum.TryParse(Reader.ReadString(), out JobType)) { LoadedSet.BuildJobs.Add(new BuildJob(ProjectRef, Config, Platform, JobType)); } } _BuildJobSetsCollection.Add(LoadedSet); } } EnsureDefaultBuildJobSet(); if (SetCombo.SelectedItem == null) { SetCombo.SelectedItem = _BuildJobSetsCollection[0]; } }
/// <summary> /// Called from the package class when there are options to be read out of the solution file. /// </summary> /// <param name="Stream">The stream to load the option data from.</param> public void LoadOptions(Stream Stream) { try { _BuildJobSetsCollection.Clear(); using (BinaryReader Reader = new BinaryReader(Stream)) { int SetCount = Reader.ReadInt32(); for (int SetIdx = 0; SetIdx < SetCount; SetIdx++) { BuildJobSet LoadedSet = new BuildJobSet(); LoadedSet.Name = Reader.ReadString(); int JobCount = Reader.ReadInt32(); for (int JobIdx = 0; JobIdx < JobCount; JobIdx++) { Utils.SafeProjectReference ProjectRef = new Utils.SafeProjectReference { FullName = Reader.ReadString(), Name = Reader.ReadString() }; string Config = Reader.ReadString(); string Platform = Reader.ReadString(); BuildJob.BuildJobType JobType; if (Enum.TryParse(Reader.ReadString(), out JobType)) { LoadedSet.BuildJobs.Add(new BuildJob(ProjectRef, Config, Platform, JobType)); } } _BuildJobSetsCollection.Add(LoadedSet); } } EnsureDefaultBuildJobSet(); if (SetCombo.SelectedItem == null) { SetCombo.SelectedItem = _BuildJobSetsCollection[0]; } } catch (Exception ex) { Exception AppEx = new ApplicationException("BatchBuilder failed to load options from .suo", ex); Logging.WriteLine(AppEx.ToString()); throw AppEx; } }