public void setData(string value) { length = 0; maxId = 0; string[] spl = PortUtil.splitString(value, ','); for (int i = 0; i < spl.Length; i++) { string[] spl2 = PortUtil.splitString(spl[i], '='); if (spl2.Length < 2) { continue; } try { int clock = int.Parse(spl2[0]); ensureBufferLength(length + 1); clocks[length] = clock; items[length] = new VsqBPPair(int.Parse(spl2[1]), maxId + 1); maxId++; length++; } catch (Exception ex) { serr.println("VsqBPList#setData; ex=" + ex); #if DEBUG sout.println(" i=" + i + "; spl2[0]=" + spl2[0] + "; spl2[1]=" + spl2[1]); #endif } } }
public void close() { #if DEBUG sout.println("WaveWriter#close; m_path=" + m_path); #endif if (m_stream == null) { return; } try { // 最後にWAVEチャンクのサイズ int position = (int)m_stream.Position; m_stream.Seek(4, SeekOrigin.Begin); byte[] buf = PortUtil.getbytes_uint32_le(position - 8); writeByteArray(m_stream, buf, 4); // size of data chunk int block_size = (int)(m_bit_per_sample / 8 * (int)m_channel); long size = block_size * m_total_samples; m_stream.Seek(42, SeekOrigin.Begin); buf = PortUtil.getbytes_uint32_le(size); writeByteArray(m_stream, buf, 4); m_stream.Close(); } catch (Exception ex) { serr.println("WaveWriter#close; ex=" + ex); } }
/// <summary> /// UTAUスクリプト形式に記録されているエンベロープの表現に基づき,インスタンスを構成します /// </summary> /// <param name="line">ustに記録されるエンベロープの記述行</param> public UstEnvelope(string line) { if (!line.ToLower().StartsWith("envelope=")) { return; } string[] spl = PortUtil.splitString(line, '='); if (spl.Length < 2) { return; } spl = PortUtil.splitString(spl[1], ','); if (spl.Length < 7) { return; } try { p1 = (int)double.Parse(spl[0]); p2 = (int)double.Parse(spl[1]); p3 = (int)double.Parse(spl[2]); v1 = (int)double.Parse(spl[3]); v2 = (int)double.Parse(spl[4]); v3 = (int)double.Parse(spl[5]); v4 = (int)double.Parse(spl[6]); if (spl.Length == 11) { p4 = (int)double.Parse(spl[8]); p5 = (int)double.Parse(spl[9]); v5 = (int)double.Parse(spl[10]); } } catch (Exception ex) { } }
/// <summary> /// Gets the VsqID of program change. /// </summary> /// <param name="program_change"></param> /// <returns></returns> public VsqID getSingerID(int language, int program) { VsqID ret = new VsqID(0); ret.type = VsqIDType.Singer; SingerConfig sc = null; for (int i = 0; i < m_singer_configs.Count; i++) { SingerConfig itemi = m_singer_configs[i]; if (itemi.Language == language && itemi.Program == program) { sc = itemi; break; } } if (sc == null) { sc = new SingerConfig(); } ret.IconHandle = new IconHandle(); ret.IconHandle.IconID = "$0701" + PortUtil.toHexString(sc.Language, 2) + PortUtil.toHexString(sc.Program, 2); ret.IconHandle.IDS = sc.VOICENAME; ret.IconHandle.Index = 0; ret.IconHandle.Language = sc.Language; ret.IconHandle.setLength(1); ret.IconHandle.Original = sc.Language << 8 | sc.Program; ret.IconHandle.Program = sc.Program; ret.IconHandle.Caption = ""; return(ret); }
private List <VsqHandle> writeEventListCor(ITextWriter writer, int eos) { List <VsqHandle> handles = buildHandleList(); writer.writeLine("[EventList]"); List <VsqEvent> temp = new List <VsqEvent>(); foreach (var @event in Events.iterator()) { temp.Add(@event); } temp.Sort(); int i = 0; while (i < temp.Count) { VsqEvent item = temp[i]; if (!item.ID.Equals(VsqID.EOS)) { string ids = "ID#" + PortUtil.formatDecimal("0000", item.ID.value); int clock = temp[i].Clock; while (i + 1 < temp.Count && clock == temp[i + 1].Clock) { i++; ids += ",ID#" + PortUtil.formatDecimal("0000", temp[i].ID.value); } writer.writeLine(clock + "=" + ids); } i++; } writer.writeLine(eos + "=EOS"); return(handles); }
private static String ValidateCharset(String cs) { if (cs == null || cs.Length == 0) { return(null); } cs = iText.IO.Util.StringUtil.ReplaceAll(cs.Trim(), "[\"']", ""); if (PortUtil.CharsetIsSupported(cs)) { return(cs); } StringBuilder upperCase = new StringBuilder(); for (int i = 0; i < cs.Length; i++) { upperCase.Append(char.ToUpper(cs[i])); } cs = upperCase.ToString(); if (PortUtil.CharsetIsSupported(cs)) { return(cs); } // if our this charset matching fails.... we just take the default return(null); }
public Task StartAsync() { _host = new WebHostBuilder() .Configure(appBuilder => { appBuilder.UseMiddleware <GlobalExceptionMiddleware>(_options); _options.PreWireMockMiddlewareInit?.Invoke(appBuilder); appBuilder.UseMiddleware <WireMockMiddleware>(_options); _options.PostWireMockMiddlewareInit?.Invoke(appBuilder); }) .UseKestrel(options => { #if NETSTANDARD1_3 if (_urls.Any(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) { options.UseHttps(PublicCertificateHelper.GetX509Certificate2()); } #else // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore2x foreach (string url in _urls.Where(u => u.StartsWith("http://", StringComparison.OrdinalIgnoreCase))) { PortUtil.TryExtractProtocolAndPort(url, out string host, out int port); options.Listen(System.Net.IPAddress.Loopback, port); } foreach (string url in _urls.Where(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) { PortUtil.TryExtractProtocolAndPort(url, out string host, out int port); options.Listen(System.Net.IPAddress.Loopback, port, listenOptions => { listenOptions.UseHttps(PublicCertificateHelper.GetX509Certificate2()); }); } #endif }) #if NETSTANDARD1_3 .UseUrls(_urls) #endif .Build(); IsStarted = true; #if NETSTANDARD1_3 Console.WriteLine("WireMock.Net server using netstandard1.3"); return(Task.Run(() => { _host.Run(_cts.Token); }, _cts.Token)); #else System.Console.WriteLine("WireMock.Net server using netstandard2.0"); return(Task.Run(() => { _host.Run(); }, _cts.Token)); #endif }
/// <summary> /// VOCALOID2システムが使用する辞書を読み込みます。 /// </summary> public static void loadSystemDictionaries() { if (mInitialized) { return; } // 辞書フォルダからの読込み string editor_path = VocaloSysUtil.getEditorPath(SynthesizerType.VOCALOID2); if (editor_path != "") { string path = Path.Combine(PortUtil.getDirectoryName(editor_path), "UDIC"); if (!Directory.Exists(path)) { return; } string[] files = PortUtil.listFiles(path, "*.udc"); for (int i = 0; i < files.Length; i++) { files[i] = PortUtil.getFileName(files[i]); string dict = Path.Combine(path, files[i]); mTable.Add(new SymbolTable(dict, true, false, "Shift_JIS")); } } mInitialized = true; }
public string toString() { string ret = "{Type=" + type; if (type == VsqIDType.Anote) { ret += ", Length=" + getLength(); ret += ", Note#=" + Note; ret += ", Dynamics=" + Dynamics; ret += ", PMBendDepth=" + PMBendDepth; ret += ", PMBendLength=" + PMBendLength; ret += ", PMbPortamentoUse=" + PMbPortamentoUse; ret += ", DEMdecGainRate=" + DEMdecGainRate; ret += ", DEMaccent=" + DEMaccent; if (LyricHandle != null) { ret += ", LyricHandle=h#" + PortUtil.formatDecimal("0000", LyricHandle_index); } if (VibratoHandle != null) { ret += ", VibratoHandle=h#" + PortUtil.formatDecimal("0000", VibratoHandle_index); ret += ", VibratoDelay=" + VibratoDelay; } } else if (type == VsqIDType.Singer) { ret += ", IconHandle=h#" + PortUtil.formatDecimal("0000", IconHandle_index); } ret += "}"; return(ret); }
public VsqEvent(string line) { string[] spl = PortUtil.splitString(line, new char[] { '=' }); Clock = int.Parse(spl[0]); if (spl[1].Equals("EOS")) { ID = VsqID.EOS; } }
private void btnOk_Click(object sender, EventArgs e) { if (oldPlugins != null) { // 削除されたスクリプトをアンインストールする foreach (string file in oldPlugins) { if (!getPlugins().Contains(file)) { string name = getPluginName(file); if (name != "") { string script_path = Path.Combine(Utility.getScriptPath(), name + ".txt"); if (File.Exists(script_path)) { PortUtil.deleteFile(script_path); } } } } } foreach (string file in getPlugins()) { if (!File.Exists(file)) { continue; } string name = getPluginName(file); if (name == "") { continue; } char[] invalid_classname = new char[] { ' ', '!', '#', '$', '%', '&', '\'', '(', ')', '=', '-', '~', '^', '`', '@', '{', '}', '[', ']', '+', '*', ';', '.' }; foreach (char c in invalid_classname) { name = name.Replace(c, '_'); } string text = TEXT; string code = text.Replace("{0}", name); code = code.Replace("{1}", file); using (StreamWriter sw = new StreamWriter(Path.Combine(Utility.getScriptPath(), name + ".txt"))) { sw.WriteLine(code); } } if (AppManager.mMainWindow != null) { VoidDelegate deleg = new VoidDelegate(AppManager.mMainWindow.updateScriptShortcut); if (deleg != null) { AppManager.mMainWindow.Invoke(deleg); } } }
/// <summary> /// 指定されたディレクトリにある言語設定ファイルを全て読込み、メッセージリストに追加します /// </summary> /// <param name="directory"></param> public static void loadMessages(string directory) { s_messages.Clear(); string[] files = PortUtil.listFiles(directory, ".po"); for (int i = 0; i < files.Length; i++) { string name = PortUtil.getFileName(files[i]); string fname = Path.Combine(directory, name); appendFromFile(fname); } }
public Object clone() { string[] spl = PortUtil.splitString(Color, new char[] { ',' }, 3); int r = int.Parse(spl[0]); int g = int.Parse(spl[1]); int b = int.Parse(spl[2]); VsqCommon res = new VsqCommon(Name, r, g, b, DynamicsMode, PlayMode); res.Version = Version; res.LastPlayMode = LastPlayMode; return(res); }
public void write(string file) { StreamWriter sw = null; try { sw = new StreamWriter(file, false, new UTF8Encoding(false)); if (!poHeader.Equals("")) { sw.WriteLine("msgid \"\""); sw.WriteLine("msgstr \"\""); string[] spl = PortUtil.splitString(poHeader, new char[] { (char)0x0d, (char)0x0a }, true); for (int i = 0; i < spl.Length; i++) { string line = spl[i]; sw.WriteLine("\"" + line + "\\" + "n\""); } sw.WriteLine(); } else { sw.WriteLine("msgid \"\""); sw.WriteLine("msgstr \"\""); sw.WriteLine("\"Content-Type: text/plain; charset=UTF-8\\" + "n\""); sw.WriteLine("\"Content-Transfer-Encoding: 8bit\\" + "n\""); sw.WriteLine(); } foreach (var key in list.Keys) { string skey = key.Replace("\n", "\\n\"\n\""); MessageBodyEntry mbe = list[key]; string s = mbe.message; List <string> location = mbe.location; int count = location.Count; for (int i = 0; i < count; i++) { sw.WriteLine("#: " + location[i]); } sw.WriteLine("msgid \"" + skey + "\""); s = s.Replace("\n", "\\n\"\n\""); sw.WriteLine("msgstr \"" + s + "\""); sw.WriteLine(); } } catch (Exception ex) { } finally { if (sw != null) { try { sw.Close(); } catch (Exception ex2) { } } } }
public void write(string str) { int len = PortUtil.getStringLength(str); int newSize = length + len; int offset = length; ensureCapacity(newSize); for (int i = 0; i < len; i++) { array[offset + i] = str[i]; } length = newSize; }
public void setData(string value) { m_list.Clear(); string[] spl = PortUtil.splitString(value, ','); for (int i = 0; i < spl.Length; i++) { string[] spl2 = PortUtil.splitString(spl[i], '='); if (spl2.Length < 2) { continue; } m_list.Add(new VibratoBPPair((float)double.Parse(spl2[0]), int.Parse(spl2[1]))); } }
/// <summary> /// 指定したディレクトリにある拡張辞書ファイル(拡張子*.eudc)を全て読み込みます /// </summary> /// <param name="directory"></param> public static void loadAllDictionaries(string directory) { // 起動ディレクトリ if (Directory.Exists(directory)) { string[] files2 = PortUtil.listFiles(directory, "*.eudc"); for (int i = 0; i < files2.Length; i++) { files2[i] = PortUtil.getFileName(files2[i]); string dict = Path.Combine(directory, files2[i]); mTable.Add(new SymbolTable(dict, true, false, "UTF-8")); } } }
/// <summary> /// 指定したトラックのレンダラーを変更します /// </summary> /// <param name="track"></param> /// <param name="new_renderer"></param> /// <param name="singers"></param> public void changeRenderer(string new_renderer, List <VsqID> singers) { VsqID default_id = null; int singers_size = singers.Count; if (singers_size <= 0) { default_id = new VsqID(); default_id.type = VsqIDType.Singer; IconHandle singer_handle = new IconHandle(); singer_handle.IconID = "$0701" + PortUtil.toHexString(0, 4); singer_handle.IDS = "Unknown"; singer_handle.Index = 0; singer_handle.Language = 0; singer_handle.setLength(1); singer_handle.Original = 0; singer_handle.Program = 0; singer_handle.Caption = ""; default_id.IconHandle = singer_handle; } else { default_id = singers[0]; } for (Iterator <VsqEvent> itr = getSingerEventIterator(); itr.hasNext();) { VsqEvent ve = itr.next(); IconHandle singer_handle = (IconHandle)ve.ID.IconHandle; int program = singer_handle.Program; bool found = false; for (int i = 0; i < singers_size; i++) { VsqID id = singers[i]; if (program == singer_handle.Program) { ve.ID = (VsqID)id.clone(); found = true; break; } } if (!found) { VsqID add = (VsqID)default_id.clone(); add.IconHandle.Program = program; ve.ID = add; } } MetaText.Common.Version = new_renderer; }
/// <summary> /// 指定した文字列が発音記号として有効かどうかを判定します。 /// </summary> /// <param name="symbol"></param> /// <returns></returns> public static bool isValidSymbol(string symbol) { foreach (string s in _SYMBOL_VOWEL_JP) { if (s == symbol) { return(true); } } foreach (string s in _SYMBOL_CONSONANT_JP) { if (s == symbol) { return(true); } } foreach (string s in _SYMBOL_VOWEL_EN) { if (s == symbol) { return(true); } } foreach (string s in _SYMBOL_CONSONANT_EN) { if (s == symbol) { return(true); } } // ブレスの判定 int strlen = PortUtil.getStringLength(symbol); if (symbol.StartsWith("br") && strlen > 2) { string s = symbol.Substring(2); try { // br001とかをfalseにするためのチェック int num = int.Parse(s); if (s.Equals("" + num)) { return(true); } } catch (Exception ex) { } } return(false); }
public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes) { Check.NotNull(options, nameof(options)); Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes)); foreach (string uriPrefix in uriPrefixes) { Urls.Add(uriPrefix); PortUtil.TryExtractProtocolAndPort(uriPrefix, out string host, out int port); Ports.Add(port); } _options = options; }
public void append(double[] L, double[] R, int length) { try { if (m_bit_per_sample == 8) { if (m_channel == 1) { for (int i = 0; i < length; i++) { m_stream.WriteByte((byte)((L[i] + R[i] + 2.0) * 63.75)); } } else { for (int i = 0; i < length; i++) { m_stream.WriteByte((byte)((L[i] + 1.0) * 127.5)); m_stream.WriteByte((byte)((R[i] + 1.0) * 127.5)); } } } else { byte[] buf; if (m_channel == 1) { for (int i = 0; i < length; i++) { buf = PortUtil.getbytes_int16_le((short)((L[i] + R[i]) * 16384.0)); writeByteArray(m_stream, buf, 2); } } else { for (int i = 0; i < length; i++) { buf = PortUtil.getbytes_int16_le((short)(L[i] * 32768.0)); writeByteArray(m_stream, buf, 2); buf = PortUtil.getbytes_int16_le((short)(R[i] * 32768.0)); writeByteArray(m_stream, buf, 2); } } } m_total_samples += (int)length; } catch (Exception ex) { serr.println("WaveWriter#append(double[],double[],int); ex=" + ex); } }
public new static MapperServer Start() { int port = PortUtil.FindFreeTcpPort(); UrlPrefix = "http://localhost:" + port + "/"; var server = new MapperServer( context => { LastRequestMessage = new HttpListenerRequestMapper().Map(context.Request); context.Response.Close(); }, UrlPrefix); ((TinyHttpServer)server).Start(); return(server); }
/// <summary>Parse out a charset from a content type header.</summary> /// <remarks> /// Parse out a charset from a content type header. If the charset is not supported, returns null (so the default /// will kick in.) /// </remarks> /// <param name="contentType">e.g. "text/html; charset=EUC-JP"</param> /// <returns>"EUC-JP", or null if not found. Charset is trimmed and uppercased.</returns> internal static String GetCharsetFromContentType(String contentType) { if (contentType == null) { return(null); } Match m = iText.IO.Util.StringUtil.Match(charsetPattern, contentType); if (PortUtil.IsSuccessful(m)) { String charset = iText.IO.Util.StringUtil.Group(m, 1).Trim(); charset = charset.Replace("charset=", ""); return(ValidateCharset(charset)); } return(null); }
/// <exception cref="System.IO.IOException"/> internal static ByteBuffer ReadFileToByteBuffer(FileInfo file) { FileStream randomAccessFile = null; try { randomAccessFile = PortUtil.GetReadOnlyRandomAccesFile(file); byte[] bytes = new byte[(int)randomAccessFile.Length]; randomAccessFile.ReadFully(bytes); return(ByteBuffer.Wrap(bytes)); } finally { if (randomAccessFile != null) { randomAccessFile.Dispose(); } } }
public void append(short[] L, short[] R) { int total = Math.Min(L.Length, R.Length); if (m_bit_per_sample == 8) { if (m_channel == 1) { for (int i = 0; i < total; i++) { m_stream.WriteByte((byte)(((L[i] + R[i]) / 2f + 32768f) / 255f)); } } else { for (int i = 0; i < total; i++) { m_stream.WriteByte((byte)((L[i] + 32768f) / 255f)); m_stream.WriteByte((byte)((R[i] + 32768f) / 255f)); } } } else { byte[] buf; if (m_channel == 1) { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le((short)((L[i] + R[i]) / 2)); writeByteArray(m_stream, buf, 2); } } else { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le(L[i]); writeByteArray(m_stream, buf, 2); buf = PortUtil.getbytes_int16_le(R[i]); writeByteArray(m_stream, buf, 2); } } } m_total_samples += (int)total; }
public void append(float[] L, float[] R) { int total = Math.Min(L.Length, R.Length); if (m_bit_per_sample == 8) { if (m_channel == 1) { for (int i = 0; i < total; i++) { m_stream.WriteByte((byte)((L[i] + R[i] + 2.0f) * 63.75f)); } } else { for (int i = 0; i < total; i++) { m_stream.WriteByte((byte)((L[i] + 1.0f) * 127.5f)); m_stream.WriteByte((byte)((R[i] + 1.0f) * 127.5f)); } } } else { byte[] buf; if (m_channel == 1) { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le((short)((L[i] + R[i]) * 16384f)); writeByteArray(m_stream, buf, 2); } } else { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le((short)(L[i] * 32768f)); writeByteArray(m_stream, buf, 2); buf = PortUtil.getbytes_int16_le((short)(R[i] * 32768f)); writeByteArray(m_stream, buf, 2); } } } m_total_samples += (int)total; }
public void append(double[] L) { int total = L.Length; if (m_bit_per_sample == 8) { if (m_channel == 1) { for (int i = 0; i < total; i++) { m_stream.WriteByte((byte)((L[i] + 1.0) * 127.5)); } } else { for (int i = 0; i < total; i++) { byte b = (byte)((L[i] + 1.0) * 127.5); m_stream.WriteByte(b); m_stream.WriteByte(b); } } } else { byte[] buf; if (m_channel == 1) { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le((short)(L[i] * 32768.0)); writeByteArray(m_stream, buf, 2); } } else { for (int i = 0; i < total; i++) { buf = PortUtil.getbytes_int16_le((short)(L[i] * 32768.0)); writeByteArray(m_stream, buf, 2); writeByteArray(m_stream, buf, 2); } } } m_total_samples += (int)total; }
private static void separateEntryAndMessage(string source, ByRef <string> entry, ByRef <string> message) { string line = source.Trim(); entry.value = ""; message.value = ""; if (PortUtil.getStringLength(line) <= 0) { return; } int index_space = line.IndexOf(' '); int index_dquoter = line.IndexOf('"'); int index = Math.Min(index_dquoter, index_space); entry.value = line.Substring(0, index); message.value = line.Substring(index_dquoter + 1); message.value = message.value.Substring(0, PortUtil.getStringLength(message.value) - 1); }
public AspNetCoreSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes) { Check.NotNull(options, nameof(options)); Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes)); _logger = options.Logger ?? new WireMockConsoleLogger(); foreach (string uriPrefix in uriPrefixes) { Urls.Add(uriPrefix); PortUtil.TryExtractProtocolAndPort(uriPrefix, out string host, out int port); Ports.Add(port); } _options = options; _urls = uriPrefixes; }
// TODO refactor into interface /// <summary> /// Parses a stream into a /// <see cref="CssRuleSetParser"/> /// . /// </summary> /// <param name="stream">the stream</param> /// <param name="baseUrl">the base url</param> /// <returns> /// the resulting /// <see cref="iText.StyledXmlParser.Css.CssStyleSheet"/> /// </returns> /// <exception cref="System.IO.IOException">Signals that an I/O exception has occurred.</exception> public static CssStyleSheet Parse(Stream stream, String baseUrl) { CssParserStateController controller = new CssParserStateController(baseUrl); TextReader br = PortUtil.WrapInBufferedReader(new StreamReader(stream, Encoding.UTF8)); // TODO determine charset correctly DEVSIX-1458 char[] buffer = new char[8192]; int length; while ((length = br.Read(buffer, 0, buffer.Length)) > 0) { for (int i = 0; i < length; i++) { controller.Process(buffer[i]); } } return(controller.GetParsingResult()); }
public Led8NType(string usbVID, string usbPID, string endpointId) { m_PortUtil = new PortUtil(usbVID, usbPID, endpointId); }
public Led8NType(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) { m_PortUtil = new PortUtil(portName, baudRate, parity, dataBits, stopBits); }
public SenorDualType(string usbVID, string usbPID, string endpointId) { m_PortUtil = new PortUtil(usbVID, usbPID, endpointId); }
public VFD220EType(string usbVID, string usbPID, string endpointId) { m_PortUtil = new PortUtil(usbVID, usbPID, endpointId); }