public MetaEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parentContainer, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _parentMetaContainer = parentContainer; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _fileManager = streamManager; _rteProvider = rteProvider; _searchTimer = new Timer(SearchTimer); _stringIdTrie = stringIDTrie; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting<string>("plugins"), className); // Set Option boxes cbShowInvisibles.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles; cbShowComments.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowComments; cbShowEnumIndex.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowEnumIndex; cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation; // Load Meta RefreshEditor(MetaReader.LoadType.File); // Set init finished hasInitFinished = true; }
public ReceiveStreamManager(IStreamManager streamManager, IStreamTransferListener streamTransferListener) { Require.NotNull(streamManager, "streamManager"); _streamManager = streamManager; _streamTransferListener = streamTransferListener; }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, FieldChangeSet ignore) { _streamManager = streamManager; _baseOffset = baseOffset; _cache = cache; _ignoredFields = ignore; }
public MetaContainer(BuildInformation buildInfo, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _stringIDTrie = stringIDTrie; tbMetaEditors.SelectedIndex = (int)Settings.halomapLastSelectedMetaEditor; // Create Meta Information Tab _metaInformation = new MetaInformation(_buildInfo, _tag, _cache); tabTagInfo.Content = _metaInformation; // Create Meta Editor Tab _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie) { Padding = new Thickness(0) }; tabMetaEditor.Content = _metaEditor; // Create Plugin Editor Tab _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor); tabPluginEditor.Content = _pluginEditor; }
public MetaEditor(BuildInformation buildInfo, TagEntry tag, MetaContainer parentContainer, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _parentMetaContainer = parentContainer; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _searchTimer = new Timer(SearchTimer); _stringIDTrie = stringIDTrie; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.PluginFolder, className); // Set Invisibility box cbShowInvisibles.IsChecked = Settings.pluginsShowInvisibles; // Load Meta RefreshEditor(); // Set init finished hasInitFinished = true; }
public BspEditor(TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); _tag = tag; _cache = cache; _streamManager = streamManager; }
public Http2Client (Http2ConnectionSettings connectionSettings, IStreamManager streamManager = null, IFlowControlManager flowControlManager = null) { this.flowControlManager = flowControlManager ?? new FlowControlManager (); this.streamManager = streamManager ?? new StreamManager (this.flowControlManager); this.ConnectionSettings = connectionSettings; connection = new Http2Connection (ConnectionSettings, this.streamManager, this.flowControlManager); }
/// <summary> /// Initializes a new instance of the <see cref="BoardStreamRepository"/> class. /// </summary> /// <param name="streamManager">Underlying stream manager.</param> public BoardStreamRepository(IStreamManager streamManager) { ContractExtensions.IsNotNull(streamManager, "streamManager"); Contract.Ensures(this.streamManager != null); Contract.EndContractBlock(); this.streamManager = streamManager; }
public FileDataSourceController( ISourceDataContext context, FileDataSourceService service, IStreamManager streamManager) { this.context = context; this.service = service; this.streamManager = streamManager; }
public HostConnection(ProtoHost host, TcpClient tcpClient, IStreamManager streamManager) : base(tcpClient, streamManager, host.ServiceAssembly) { Require.NotNull(host, "host"); _host = host; IsAsync = true; }
/// <summary> /// View the selected offset as every meta value type. /// </summary> /// <param name="cacheFile">The cache file which is being read from.</param> /// <param name="streamManager">The stream manager to open the file with.</param> /// <param name="fields">The fields to display in the viewer.</param> /// <param name="cacheOffset">The initial offset to display.</param> public static void Show(ICacheFile cacheFile, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { var valueAs = new ViewValueAs(cacheFile, streamManager, fields, cacheOffset) { Owner = Settings.homeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; valueAs.Show(); }
public FileDataSourceService( ISourceDataContext context, IHandlerFactory handlerFactory, IStreamManager streamManager) : base(context) { this.streamManager = streamManager; this.handlerFactory = handlerFactory; }
public ScriptEditor(IScriptFile scriptFile, IStreamManager streamManager, string scriptDefsFile) { _scriptFile = scriptFile; _scriptDefsFile = scriptDefsFile; InitializeComponent(); Thread thrd = new Thread(DecompileScripts); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(streamManager); }
public Http2Connection (Http2ConnectionSettings connectionSettings, IStreamManager streamManager, IFlowControlManager flowControlManager) { this.flowControlManager = flowControlManager; this.streamManager = streamManager; ConnectionSettings = connectionSettings; Settings = new Http2Settings (); queue = new FrameQueue (flowControlManager); }
protected ProtoConnection(TcpClient tcpClient, IStreamManager streamManager, ServiceAssembly serviceAssembly) : base(tcpClient) { Require.NotNull(streamManager, "streamManager"); Require.NotNull(serviceAssembly, "serviceAssembly"); _serviceAssembly = serviceAssembly; _sendStreamManager = new SendStreamManager(); _receiveStreamManager = new ReceiveStreamManager(streamManager); }
public ScriptEditor(EngineDescription buildInfo, IScriptFile scriptFile, IStreamManager streamManager) { _buildInfo = buildInfo; _scriptFile = scriptFile; InitializeComponent(); var thrd = new Thread(DecompileScripts); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(streamManager); }
/// <summary> /// View the selected offset as every meta value type. /// </summary> /// <param name="cacheFile">The cache file which is being read from.</param> /// <param name="buildInfo">Build information for the engine.</param> /// <param name="streamManager">The stream manager to open the file with.</param> /// <param name="fields">The fields to display in the viewer.</param> /// <param name="cacheOffset">The initial offset to display.</param> public static void Show(ICacheFile cacheFile, EngineDescription buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { var valueAs = new ViewValueAs(cacheFile, buildInfo, streamManager, fields, cacheOffset) { Owner = App.AssemblyStorage.AssemblySettings.HomeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; valueAs.Show(); }
public ClientConnection(ProtoClient client, TcpClient tcpClient, string hostname, IStreamManager streamManager) : base(tcpClient, streamManager, client.ServiceAssembly) { Require.NotNull(client, "client"); Require.NotNull(hostname, "hostname"); _client = client; _hostname = hostname; Connect(); }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, BuildInformation buildInfo, FieldChangeSet ignore) { _streamManager = streamManager; BaseOffset = baseOffset; _cache = cache; _ignoredFields = ignore; // Load layouts _reflexiveLayout = buildInfo.GetLayout("reflexive"); _tagRefLayout = buildInfo.GetLayout("tag reference"); _dataRefLayout = buildInfo.GetLayout("data reference"); }
public LocaleEditor(ThirdGenCacheFile cache, IStreamManager streamManager, int index) { InitializeComponent(); _cache = cache; _streamManager = streamManager; _languageIndex = index; _currentLanguage = cache.Languages[index]; Thread thrd = new Thread(new ThreadStart(LoadLanguage)); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(); }
public MainController(IStepModel stepModel) { converter = new Converter(); streamManager = new StreamManager(); this.stepModel = stepModel; rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion"); folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings"); dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\data.json"); streamTemplatePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\streams.json");; historyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\history.json"); ; semaphoreSlim = new SemaphoreSlim(1); TryLoadSettings(); }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, EngineDescription buildInfo, LoadType type, FieldChangeSet ignore) { _streamManager = streamManager; BaseOffset = baseOffset; _cache = cache; _ignoredFields = ignore; _type = type; // Load layouts _tagBlockLayout = buildInfo.Layouts.GetLayout("tag block"); _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); }
public LocaleEditor(GameLanguage language, ICacheFile cache, IStreamManager streamManager, Trie stringIdTrie, LocaleSymbolCollection symbols) { InitializeComponent(); _currentLanguage = language; _cache = cache; _streamManager = streamManager; _symbols = symbols; StringIDTrie = stringIdTrie; // Thread the loading routine var thrd = new Thread(LoadAll); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(); }
public ViewValueAs(ICacheFile cacheFile, BuildInformation buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { InitializeComponent(); DwmDropShadow.DropShadowToWindow(this); _cacheFile = cacheFile; _reader = new MetaReader(streamManager, cacheOffset, cacheFile, buildInfo); _fields = fields; _cacheOffsetOriginal = cacheOffset; // Set Textbox txtOffset.Text = "0x" + cacheOffset.ToString("X"); // Load Meta panelMetaComponents.ItemsSource = _fields; RefreshMeta(); }
public ViewValueAs(ICacheFile cacheFile, EngineDescription buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { InitializeComponent(); DwmDropShadow.DropShadowToWindow(this); _buildInfo = buildInfo; _streamManager = streamManager; _cacheFile = cacheFile; _fields = fields; _cacheOffsetOriginal = _cacheOffset = cacheOffset; // Set Textbox txtOffset.Text = "0x" + _cacheOffset.ToString("X"); // Load Meta panelMetaComponents.ItemsSource = _fields; RefreshMeta(); }
internal ProtoHost(IPEndPoint localEndPoint, Type serviceType, ProtoHostConfiguration configuration) { Require.NotNull(localEndPoint, "localEndPoint"); Require.NotNull(serviceType, "serviceType"); LocalEndPoint = localEndPoint; Configuration = configuration ?? new ProtoHostConfiguration(); Configuration.Freeze(); ServiceAssembly = ServiceRegistry.GetAssemblyRegistration( Configuration.ServiceAssembly ?? serviceType.Assembly ); Service = ServiceAssembly.GetServiceRegistration(serviceType); _streamManager = Configuration.StreamManager ?? new MemoryStreamManager(); Start(); }
public ViewValueAs(ICacheFile cacheFile, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { InitializeComponent(); DwmDropShadow.DropShadowToWindow(this); _stream = streamManager.OpenRead(); _reader = new MetaReader(streamManager, cacheOffset, cacheFile); _fields = fields; _cacheOffset = _cacheOffsetOriginal = cacheOffset; // Set Textbox txtOffset.Text = "0x" + _cacheOffset.ToString("X"); btnRefresh_Click(null, null); // Load Plugin Path _examplePath = string.Format("{0}\\Examples\\ThirdGenExample.xml", VariousFunctions.GetApplicationLocation() + @"Plugins"); // Load Meta RefreshMeta(); }
public MetaContainer(BuildInformation buildInfo, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); _tag = tag; _buildInfo = buildInfo; _cache = cache; tbMetaEditors.SelectedIndex = (int)Settings.halomapLastSelectedMetaEditor; // Create Meta Information Tab MetaInformation metaInformation = new MetaInformation(_buildInfo, _tag, _cache); tabTagInfo.Content = metaInformation; // Create Meta Editor Tab MetaEditor metaEditor = new MetaEditor(_buildInfo, _tag, tags, _cache, streamManager); tabMetaEditor.Content = metaEditor; // Create Plugin Editor Tab PluginEditor pluginEditor = new PluginEditor(_buildInfo, _tag, this, metaEditor); tabPluginEditor.Content = pluginEditor; }
public MetaContainer(EngineDescription buildInfo, string cacheLocation, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _cacheLocation = cacheLocation; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _stringIDTrie = stringIDTrie; tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor; // Create Meta Information Tab //_metaInformation = new MetaInformation(_buildInfo, _tag, _cache); //tabTagInfo.Content = _metaInformation; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Info) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } // Create Meta Editor Tab _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie); tabMetaEditor.Content = _metaEditor; // Create Plugin Editor Tab _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor); tabPluginEditor.Content = _pluginEditor; // Create Raw Tabs #region Models //if (_cache.ResourceMetaLoader.SupportsRenderModels && _tag.RawTag.Group.Magic == CharConstant.FromString("mode")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Model) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion #region Sound //if (_cache.ResourceMetaLoader.SupportsSounds && _tag.RawTag.Group.Magic == CharConstant.FromString("snd!")) //{ // tabSoundEditor.Visibility = Visibility.Visible; // tabSoundEditor.Content = new SoundEditor(_buildInfo, _cacheLocation, _tag, _cache, _streamManager); //} //else { tabSoundEditor.Visibility = Visibility.Collapsed; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Sound) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } } #endregion }
/// <inheritdoc /> public abstract IFileSystem Clone(IStreamManager streamManager);
public ChromatogramLibrary(ChromatogramLibrarySpec chromatogramLibrarySpec, IStreamManager streamManager) : this(chromatogramLibrarySpec) { _pooledSessionFactory = new PooledSessionFactory(streamManager.ConnectionPool, typeof(ChromLibEntity), chromatogramLibrarySpec.FilePath); }
/// <summary> /// Identify a file with a single plugin. /// </summary> /// <param name="identifyFile">The plugin to identify with.</param> /// <param name="fileSystem">The file system to retrieve the file from.</param> /// <param name="filePath">The path of the file to identify.</param> /// <param name="streamManager">The stream manager.</param> /// <returns>If hte identification was successful.</returns> private async Task <bool> TryIdentifyFileAsync(IIdentifyFiles identifyFile, IFileSystem fileSystem, UPath filePath, IStreamManager streamManager) { // 1. Identify plugin var identifyContext = new IdentifyContext(streamManager.CreateTemporaryStreamProvider()); var identifyResult = await identifyFile.IdentifyAsync(fileSystem, filePath, identifyContext); // 2. Close all streams opened by the identifying method streamManager.ReleaseAll(); return(identifyResult); }
/// <summary> /// Test only method for creating a <see cref="XHunterLibrary"/> file /// from another loaded <see cref="Library"/>. Should this move into test project? /// </summary> /// <param name="streamManager">Provides access to the file system</param> /// <param name="path">Path to write to</param> /// <param name="library">The loaded library to use as a data source</param> /// <param name="lowIntensity">True to use 20 lowest intensity peaks for bad spectrum</param> public static void Write(IStreamManager streamManager, string path, Library library, bool lowIntensity) { using (FileSaver fs = new FileSaver(path, streamManager)) using (Stream outStream = streamManager.CreateStream(fs.SafeName, FileMode.Create, true)) { outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); outStream.Write(BitConverter.GetBytes(library.SpectrumCount), 0, sizeof(int)); byte[] header = new byte[256 - 8]; const string headerText = @"HLF v=2 s=test.hlf d=2009.02.04"; Encoding.UTF8.GetBytes(headerText, 0, headerText.Length, header, 0); outStream.Write(header, 0, header.Length); SequenceMassCalc calc = new SequenceMassCalc(MassType.Monoisotopic); byte[] seqBuffer = new byte[1024]; foreach (var key in library.Keys) { SpectrumPeaksInfo peaksInfo; if (!library.TryLoadSpectrum(key, out peaksInfo)) { continue; } // Fake X! Hunter filtering by choosing just the to 20 peaks SpectrumPeaksInfo.MI[] peaks = peaksInfo.Peaks.ToArray(); // Sort by intensity if (lowIntensity) { Array.Sort(peaks, (p1, p2) => Comparer.Default.Compare(p1.Intensity, p2.Intensity)); // ascending } else { Array.Sort(peaks, (p1, p2) => Comparer.Default.Compare(p2.Intensity, p1.Intensity)); // descending } float maxI = peaks.Length == 0 ? 0 : peaks[0].Intensity; // Take 20 most intense peaks SpectrumPeaksInfo.MI[] peaksFiltered = new SpectrumPeaksInfo.MI[Math.Min(20, peaks.Length)]; Array.Copy(peaks, peaksFiltered, peaksFiltered.Length); // Resort by m/z (ineffient, but this is test code) Array.Sort(peaksFiltered, (p1, p2) => Comparer.Default.Compare(p1.Mz, p2.Mz)); double totalI = 0; byte[] peakBytes = new byte[(sizeof(byte) + sizeof(float)) * peaksFiltered.Length]; for (int i = 0; i < peaksFiltered.Length; i++) { var mi = peaksFiltered[i]; // Calculate the X! Hunter processed intensity value float intensity = 100f * mi.Intensity / maxI; totalI += intensity; // Fill the peaks buffer peakBytes[i] = (byte)(int)intensity; Array.Copy(BitConverter.GetBytes((float)mi.Mz), 0, peakBytes, peaksFiltered.Length + i * 4, sizeof(float)); } var sequence = key.Target.ToString(); // Only works for unmodified sequence Debug.Assert(!key.IsModified); double precursorMH = calc.GetPrecursorMass(sequence); outStream.Write(BitConverter.GetBytes(precursorMH), 0, sizeof(double)); outStream.Write(BitConverter.GetBytes(key.Charge), 0, sizeof(int)); // Value rounded for consistent serialization round-tripping float i2 = (float)Math.Round(Math.Sqrt(totalI), 4); outStream.Write(BitConverter.GetBytes(i2), 0, sizeof(float)); outStream.Write(BitConverter.GetBytes(0.0001f), 0, sizeof(float)); outStream.Write(BitConverter.GetBytes(sequence.Length), 0, sizeof(int)); // Sequence Encoding.UTF8.GetBytes(sequence, 0, sequence.Length, seqBuffer, 0); outStream.Write(seqBuffer, 0, sequence.Length); // Peaks outStream.Write(BitConverter.GetBytes(peaksFiltered.Length), 0, sizeof(int)); outStream.Write(peakBytes, 0, peakBytes.Length); // Modifications outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // Homologs outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); } streamManager.Finish(outStream); fs.Commit(); } }
public Server(int port, IStreamManager streamManager) { listener = new TcpListener(IPAddress.Any, port); this.streamManager = streamManager; }
/// <inheritdoc /> public override IFileSystem Clone(IStreamManager streamManager) { return(new PhysicalFileSystem(streamManager)); }
/// <summary> /// Initializes a new instance of the <see cref="PayloadStreamAssembler"/> class. /// </summary> /// <param name="streamManager">The <see cref="IStreamManager"/> managing the stream being assembled.</param> /// <param name="id">The ID of this instance.</param> public PayloadStreamAssembler(IStreamManager streamManager, Guid id) { _streamManager = streamManager ?? new StreamManager(); Id = id; }
public Printer(IOManager consoleManager, IStreamManager streamManager) { ConsoleManager = consoleManager; StreamManager = streamManager; }
/// <inheritdoc /> public override IFileSystem Clone(IStreamManager streamManager) { return(new PhysicalFileSystem(streamManager, GetOrCreateDispatcher().Get())); }
/// <inheritdoc /> public PhysicalFileSystem(IStreamManager streamManager) : base(streamManager) { }
public ExitCommand(IStreamManager streamManager, IOManager consoleManager, IUserSession userSession) { StreamManager = streamManager; ConsoleManager = consoleManager; UserSession = userSession; }
/// <summary> /// Create a <see cref="AfiFileSystem"/> based on the given <see cref="IArchiveState"/>. /// </summary> /// <param name="stateInfo"><see cref="IStateInfo"/> to create the file system from.</param> /// <param name="path">The path of the virtual file system.</param> /// <param name="streamManager">The stream manager for this file system.</param> /// <returns>The created <see cref="IFileSystem"/> for this state.</returns> public static IFileSystem CreateAfiFileSystem(IStateInfo stateInfo, UPath path, IStreamManager streamManager) { var fileSystem = (IFileSystem) new AfiFileSystem(stateInfo, streamManager); if (path != UPath.Empty && path != UPath.Root) { fileSystem = new SubFileSystem(fileSystem, path); } return(fileSystem); }
/// <summary> /// Initializes a new instance of the <see cref="PayloadStreamAssembler"/> class. /// </summary> /// <param name="streamManager">The <see cref="IStreamManager"/> managing the stream being assembled.</param> /// <param name="id">The ID of this instance.</param> /// <param name="type">The type of the content contained within the stream.</param> /// <param name="length">The length of the content contained within the stream.</param> public PayloadStreamAssembler(IStreamManager streamManager, Guid id, string type, int?length) : this(streamManager, id) { ContentType = type; ContentLength = length; }
/// <summary> /// Test only method for creating a <see cref="BiblioSpecLibrary"/> file /// from another loaded <see cref="Library"/>. Should this move into test project? /// </summary> /// <param name="streamManager">Provides access to the file system</param> /// <param name="path">Path to write to</param> /// <param name="library">The loaded library to use as a data source</param> public static void Write(IStreamManager streamManager, string path, Library library) { using (FileSaver fs = new FileSaver(path, streamManager)) using (Stream outStream = streamManager.CreateStream(fs.SafeName, FileMode.Create, true)) { outStream.Write(BitConverter.GetBytes(library.SpectrumCount), 0, sizeof(int)); // num_spectra outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // filtered outStream.Write(BitConverter.GetBytes(1), 0, sizeof(int)); // version1 outStream.Write(BitConverter.GetBytes(1), 0, sizeof(int)); // version2 outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // next_id SequenceMassCalc calc = new SequenceMassCalc(MassType.Monoisotopic); byte[] seqBuffer = new byte[1024]; int scanNum = 1; foreach (var key in library.Keys) { SpectrumPeaksInfo peaksInfo; if (!library.TryLoadSpectrum(key, out peaksInfo)) { continue; } var sequence = key.Target.Sequence; // Only works for unmodified sequence Debug.Assert(!key.IsModified); var precursorMH = calc.GetPrecursorMass(sequence); int charge = key.Charge; float precursorMz = (float)SequenceMassCalc.GetMZ(precursorMH, charge); outStream.Write(BitConverter.GetBytes(scanNum), 0, sizeof(int)); // scan_num outStream.Write(BitConverter.GetBytes(2), 0, sizeof(int)); // scan_type outStream.Write(BitConverter.GetBytes(precursorMz), 0, sizeof(float)); // pre_mz outStream.Write(BitConverter.GetBytes(charge), 0, sizeof(int)); // scan_type outStream.Write(BitConverter.GetBytes(0f), 0, sizeof(int)); // r_time outStream.Write(BitConverter.GetBytes(peaksInfo.Peaks.Length), 0, sizeof(int)); // num_peaks outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // 32-bit peak_ptr outStream.Write(BitConverter.GetBytes(sequence.Length), 0, sizeof(int)); // seq_len outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // annot outStream.Write(BitConverter.GetBytes(scanNum), 0, sizeof(int)); // copies (bogus value for ranking) outStream.Write(BitConverter.GetBytes(0), 0, sizeof(int)); // lib_id scanNum++; // Sequence int len = sequence.Length; seqBuffer[len] = 0; Encoding.UTF8.GetBytes(sequence, 0, len, seqBuffer, 0); outStream.Write(seqBuffer, 0, len + 1); // Modifications const string zeros = "000000000000000000000000000000000000000000000000000"; Encoding.UTF8.GetBytes(zeros.Substring(0, len), 0, len, seqBuffer, 0); outStream.Write(seqBuffer, 0, len + 1); // Peaks foreach (var mi in peaksInfo.Peaks) { outStream.Write(BitConverter.GetBytes((float)mi.Mz), 0, sizeof(float)); outStream.Write(BitConverter.GetBytes(mi.Intensity), 0, sizeof(float)); } } streamManager.Finish(outStream); fs.Commit(); } }
/// <summary> /// Creates a <see cref="MemoryFileSystem"/> based on the given <see cref="Stream"/>. /// </summary> /// <param name="stream">The <see cref="Stream"/> to add to the file system.</param> /// <param name="streamName">The path of the stream in the file system.</param> /// <param name="streamManager">The stream manager for this file system.</param> /// <returns>The created <see cref="IFileSystem"/> for this stream.</returns> public static IFileSystem CreateMemoryFileSystem(Stream stream, UPath streamName, IStreamManager streamManager) { // 1. Create file system var fileSystem = new MemoryFileSystem(streamManager); var directory = streamName.GetDirectory(); if (!directory.IsEmpty && !fileSystem.DirectoryExists(streamName.GetDirectory())) { fileSystem.CreateDirectory(streamName.GetDirectory()); } var createdStream = fileSystem.OpenFile(streamName, FileMode.CreateNew, FileAccess.Write); // 2. Copy data var bkPos = stream.Position; stream.Position = 0; stream.CopyTo(createdStream); stream.Position = bkPos; createdStream.Position = 0; createdStream.Close(); return(fileSystem); }
public LogoutCommand(IStreamManager streamManager, IPrinterManager printerManager, IUserSession userSession) { StreamManager = streamManager; PrinterManager = printerManager; UserSession = userSession; }
public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); _buildInfo = buildInfo; _cacheLocation = cacheLocation; _tag = tag; _cache = cache; _streamManager = streamManager; var viewModel = new ViewModel(); DataContext = viewModel; viewModel.TagName = _tag.TagFileName; viewModel.Sound = _sound; if (!_cache.ResourceMetaLoader.SupportsSounds) { IsEnabled = false; MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet."); return; } using (var reader = _streamManager.OpenRead()) { _soundResourceGestalt = _cache.LoadSoundResourceGestaltData(reader); _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader); var resourceTable = _cache.Resources.LoadResourceTable(reader); _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex); _resourcePages = new [] { _soundResource.Location.PrimaryPage, _soundResource.Location.SecondaryPage }; viewModel.ResourcePages = new ObservableCollection <ResourcePage>(_resourcePages.ToList()); } var playback = _soundResourceGestalt.SoundPlaybacks[_sound.PlaybackIndex]; var soundPermutations = new ISoundPermutation[playback.EncodedPermutationCount]; for (var i = 0; i < playback.EncodedPermutationCount; i++) { var permutation = _soundResourceGestalt.SoundPermutations[i + playback.FirstPermutationIndex]; soundPermutations[i] = permutation; viewModel.Permutations.Add(new ViewModel.ViewPermutation { Name = _cache.StringIDs.GetString(permutation.SoundName), Index = i, SoundPermutation = permutation }); } }
public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); /* * This was been fixed up to support the changes that came from sound injection, but has not really been tested * but it still isn't great/complete and was mainly only done so I didn't leave in a control where most of its code has been commented out and broken * not to mention this is all moot with MCC using external proprietary files for sounds * if i had to complete it, id probably add extra methods to SoundResourceTable and SoundGestalt to grab pitch ranges on demand instead of loading in everything every time * -Zedd */ _buildInfo = buildInfo; _cacheLocation = cacheLocation; _tag = tag; _cache = cache; _streamManager = streamManager; var viewModel = new ViewModel(); DataContext = viewModel; viewModel.TagName = _tag.TagFileName; viewModel.Sound = _sound; if (!_cache.ResourceMetaLoader.SupportsSounds) { IsEnabled = false; MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet."); return; } using (var reader = _streamManager.OpenRead()) { // load gestalt if (_cache.SoundGestalt != null) { _soundResourceTable = _cache.SoundGestalt.LoadSoundResourceTable(reader); } _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader); var resourceTable = _cache.Resources.LoadResourceTable(reader); _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex); _resourcePages = new [] { _soundResource.Location.PrimaryPage, _soundResource.Location.SecondaryPage, _soundResource.Location.TertiaryPage, }; viewModel.ResourcePages = new ObservableCollection <ResourcePage>(_resourcePages.ToList()); } for (int i = 0; i < _sound.PitchRangeCount; i++) { var pitchrange = _soundResourceTable.PitchRanges[_sound.FirstPitchRangeIndex + i]; foreach (var permutation in pitchrange.Permutations) { viewModel.Permutations.Add(new ViewModel.ViewPermutation { Name = _cache.StringIDs.GetString(permutation.Name), Index = i, SoundPermutation = permutation }); } } }
/// <summary> /// Initializes a new instance of the <see cref="DeflateCompressor" /> class. /// </summary> /// <param name="streamManager">Manager for stream.</param> public DeflateCompressor(IStreamManager streamManager) : base(streamManager) { }
/// <summary> /// Clone a <see cref="IFileSystem"/> with a new sub path. /// </summary> /// <param name="fileSystem"><see cref="IFileSystem"/> to clone.</param> /// <param name="path">The sub path of the cloned file system.</param> /// <param name="streamManager">The stream manager for this file system.</param> /// <returns>The cloned <see cref="IFileSystem"/>.</returns> public static IFileSystem CloneFileSystem(IFileSystem fileSystem, UPath path, IStreamManager streamManager) { var newFileSystem = fileSystem.Clone(streamManager); if (path != UPath.Empty) { newFileSystem = new SubFileSystem(newFileSystem, path); } return(newFileSystem); }
public MetaContainer(EngineDescription buildInfo, string cacheLocation, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _cacheLocation = cacheLocation; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _stringIDTrie = stringIDTrie; tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor; // Create Meta Information Tab //_metaInformation = new MetaInformation(_buildInfo, _tag, _cache); //tabTagInfo.Content = _metaInformation; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Info) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } // Create Meta Editor Tab _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie) { Padding = new Thickness(0) }; tabMetaEditor.Content = _metaEditor; // Create Plugin Editor Tab _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor); tabPluginEditor.Content = _pluginEditor; // Create Raw Tabs #region Models //if (_cache.ResourceMetaLoader.SupportsRenderModels && _tag.RawTag.Class.Magic == CharConstant.FromString("mode")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Model) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion #region Sound if (_cache.ResourceMetaLoader.SupportsSounds && _tag.RawTag.Class.Magic == CharConstant.FromString("snd!")) { tabSoundEditor.Visibility = Visibility.Visible; tabSoundEditor.Content = new SoundEditor(_buildInfo, _cacheLocation, _tag, _cache, _streamManager); } else { tabSoundEditor.Visibility = Visibility.Collapsed; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Sound) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } } #endregion // Load Info lblTagName.Text = tag.TagFileName != null ? tag.TagFileName + "." + tag.ClassName : "0x" + tag.RawTag.Index.Value.ToString("X"); lblDatum.Text = string.Format("Datum Index: {0}", tag.RawTag.Index); lblAddress.Text = string.Format("Memory Address: 0x{0:X8}", tag.RawTag.MetaLocation.AsPointer()); lblOffset.Text = string.Format("File Offset: 0x{0:X}", tag.RawTag.MetaLocation.AsOffset()); }
/// <inheritdoc /> public override IFileSystem Clone(IStreamManager streamManager) { var clonedFs = base.Clone(streamManager); return(new SubFileSystem(clonedFs, SubPath, Owned)); }
public Http2Client(string url, X509CertificateCollection certificates = null, IStreamManager streamManager = null, IFlowControlManager flowControlManager = null) : this(new Http2ConnectionSettings(url, certificates), streamManager, flowControlManager) { }
public async Task SetStreamManager(IStreamManager value) { value.ValidateNonNull(nameof(value)); if (SetProperty(() => StreamManager, v => streamInfo.StreamManagerId = v.Id, value)) await TransferStream(); }
public LocalStreamManager(IStreamManager sourceStreamManager) { _sourceStreamManager = sourceStreamManager; }
/// <summary> /// Creates a new instance of <see cref="FileSystem"/>. /// </summary> /// <param name="streamManager">The stream manager to scope streams in.</param> public FileSystem(IStreamManager streamManager) { ContractAssertions.IsNotNull(streamManager, nameof(streamManager)); StreamManager = streamManager; }
private EncyclopeDiaLibrary(EncyclopeDiaSpec spec, IStreamManager streamManager) : this(spec) { _pooledSqliteConnection = new PooledSqliteConnection(streamManager.ConnectionPool, FilePath); }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, BuildInformation buildInfo) : this(streamManager, baseOffset, cache, buildInfo, null) { }
public UploadController(IStreamManager streamManager, IConfiguration configuration) { _streamManager = streamManager; _fileSizeLimit = int.Parse(configuration["FileSizeLimit"]); }
public void RefreshEditor(MetaReader.LoadType type) { if (!File.Exists(_pluginPath)) { UpdateMetaButtons(false); StatusUpdater.Update("Plugin doesn't exist. It can't be loaded for this tag."); return; } // Store the current search selection so it can be restored int searchSelectedItem = comboSearchResults.SelectedIndex; // Set the stream manager and base offset to use based upon the LoadType IStreamManager streamManager = null; uint baseOffset = 0; switch (type) { case MetaReader.LoadType.File: streamManager = _fileManager; baseOffset = (uint)_tag.RawTag.MetaLocation.AsOffset(); break; case MetaReader.LoadType.Memory: if (_rteProvider == null) { goto default; } if (_rteProvider.GetMetaStream(_cache) == null) { ShowConnectionError(); return; } streamManager = new RTEStreamManager(_rteProvider, _cache); baseOffset = _tag.RawTag.MetaLocation.AsPointer(); break; default: MetroMessageBox.Show("Not Supported", "That feature is not supported for this game."); return; } // Load Plugin File using (XmlReader xml = XmlReader.Create(_pluginPath)) { _pluginVisitor = new ThirdGenPluginVisitor(_tags, _stringIdTrie, _cache.MetaArea, App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles); AssemblyPluginLoader.LoadPlugin(xml, _pluginVisitor); } _changeTracker = new FieldChangeTracker(); _fileChanges = new FieldChangeSet(); _memoryChanges = new FieldChangeSet(); var metaReader = new MetaReader(streamManager, baseOffset, _cache, _buildInfo, type, _fileChanges); _flattener = new ReflexiveFlattener(metaReader, _changeTracker, _fileChanges); _flattener.Flatten(_pluginVisitor.Values); metaReader.ReadFields(_pluginVisitor.Values); panelMetaComponents.ItemsSource = _pluginVisitor.Values; // Start monitoring fields for changes _changeTracker.RegisterChangeSet(_fileChanges); _changeTracker.RegisterChangeSet(_memoryChanges); _changeTracker.Attach(_pluginVisitor.Values); // Update Meta Toolbar UpdateMetaButtons(true); // Refresh search if needed if (searchSelectedItem != -1) { SearchTimer(null); if (searchSelectedItem <= (comboSearchResults.Items.Count - 1)) { comboSearchResults.SelectedIndex = searchSelectedItem; } } }
public MetaContainer(EngineDescription buildInfo, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _stringIDTrie = stringIDTrie; tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor; // Create Meta Information Tab _metaInformation = new MetaInformation(_buildInfo, _tag, _cache); tabTagInfo.Content = _metaInformation; // Create Meta Editor Tab _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie) { Padding = new Thickness(0) }; tabMetaEditor.Content = _metaEditor; // Create Plugin Editor Tab _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor); tabPluginEditor.Content = _pluginEditor; // Create Raw Tabs #region Models //if (_cache.ResourceMetaLoader.SupportsRenderModels && _tag.RawTag.Class.Magic == CharConstant.FromString("mode")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Model) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion #region BSP /*if (true && _tag.RawTag.Class.Magic == CharConstant.FromString("sbsp")) // add some manual check here akarias, since you code isn't in blamite * { * tabBspEditor.Visibility = Visibility.Visible; * tabBspEditor.Content = new BspEditor(_tag, _cache, _streamManager); * } * else*/ { tabBspEditor.Visibility = Visibility.Collapsed; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Bsp) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } } #endregion #region Sound //if (_cache.ResourceMetaLoader.SupportsSounds && _tag.RawTag.Class.Magic == CharConstant.FromString("snd!")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Sound) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion }