public async Task <T> Execute <T>(string spName, SqlParameter[] spParams, ReadHandler <Task <T> > read) where T : class { using (SqlConnection connection = new SqlConnection(_connectionString)) { using (SqlCommand command = new SqlCommand { Connection = connection, CommandType = CommandType.StoredProcedure, CommandText = spName, }) { if (spParams != null) { command.Parameters.AddRange(spParams); } if (connection.State != ConnectionState.Open) { connection.Open(); } T result = null; using (SqlDataReader reader = await command.ExecuteReaderAsync()) { if (read != null) { result = await read(reader); } } return(result); } } }
public bool ReadList <T>(ref List <T> result, ReadHandler <T> reader) where T : struct { ushort count = 0; if (!ReadUInt16(ref count)) { return(false); } if (result == null) { result = new List <T>(count); } else { result.Clear(); } for (int i = 0; i < count; i++) { T?item = reader(this); if (!item.HasValue) { return(false); } result.Add(item.Value); } return(true); }
internal static bool Read(string filename, ReadHandler handler, VoidDelegate onFail = null) { if (!File.Exists(filename)) { return(false); } try { using (Stream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) using (SerializationReader reader = new SerializationReader(stream)) { handler(reader); return(true); } } catch (Exception e) { onFail?.Invoke(); try { GeneralHelper.CreateBackup(filename); } catch { } ErrorSubmission.Submit(new OsuError(e) { Feedback = "database-corrupt" }); return(false); } }
internal void Write(PexWriteMeta write) { write.WriteString(Name); write.WriteString(TypeName); write.WriteString(DocString); write.Writer.Write(RawUserFlags); var flags = (byte)Flags; write.Writer.Write(flags); if ((flags & 4) != 0) { write.WriteString(AutoVarName); } if ((flags & 5) == 1) { ReadHandler?.Write(write); } if ((flags & 6) == 2) { WriteHandler?.Write(write); } }
private void FormMain_Load(object sender, EventArgs e) { OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "Текстовые файлы (.txt)|*.txt|Все файлы (*.*)|*.*"; fd.FilterIndex = 0; fd.CheckFileExists = false; MemoryFileHandler fileHandler = null; if (MemoryFileHandler.CheckFileExistInMemory()) { fileHandler = MemoryFileHandler.CreateInstance(fromMemory: true); } else { if (fd.ShowDialog() == DialogResult.OK) { fileHandler = MemoryFileHandler.CreateInstance(fd.FileName); } else { Close(); } } username = UsernameGenerator.CreateName(); writeHandler = new WriteHandler(username, fileHandler); readHandler = new ReadHandler(fileHandler); readHandler.NewMessages += ReadHandler_NewMessage; readHandler.StartChecking(); labelUsername.Text = "Имя: " + username; textBoxMessageText.MaxLength = Encoding.Unicode.GetMaxCharCount(MessageModel.COUNT_TEXT); }
static DataStreamIO() { if (Reader != null && Writer != null) { return; } Tuple <Delegate, Delegate> pair; if (RWTable.TryGetValue(typeof(TE), out pair)) { Reader = (ReadHandler <TE>)pair.Item1; Writer = (WriteHandler <TE>)pair.Item2; } else { if (typeof(IDataSerializer).IsAssignableFrom(typeof(TE))) { Reader = new ReadHandler <TE>((delegate(DataStream ds, out TE value) { value = Helpers.FastConstructor <TE> .Create(); var dataSerializer = (IDataSerializer)value; return(ds.TryRead(dataSerializer)); })); Writer = new WriteHandler <TE>((delegate(DataStream ds, TE value) { var dataSerializer = (IDataSerializer)value; ds.Write(dataSerializer); })); } else { throw new Exception("Unknown type"); } } }
protected override void Read(ReadHandler readHandler) { int frameCount = wasapi.AudioClient.BufferSize; int durationMs = 1000 * frameCount / Format.SampleRate; if (wasapi.EventSync) { if (!eventObject.WaitOne(durationMs * 2, false)) { return; } } else { Thread.Sleep(durationMs / 2); } int offset = 0; while (true) { int packetSize = captureClient.GetNextPacketSize(); if (packetSize == 0) { break; } int frames; AudioClientBufferFlags flags; IntPtr bufferPtr = captureClient.GetBuffer(out frames, out flags); int readBytes = frames * Format.BlockAlign; if (recordBuffer.Length - offset < readBytes && offset > 0) { readHandler(recordBuffer, offset); offset = 0; } if ((flags & AudioClientBufferFlags.Silent) != 0) { Array.Clear(recordBuffer, offset, readBytes); } else { Marshal.Copy(bufferPtr, recordBuffer, offset, readBytes); } offset += readBytes; captureClient.ReleaseBuffer(frames); } if (offset > 0) { readHandler(recordBuffer, offset); } }
public DBAccess() { connection.DataSource = @"MSI"; //the data source of the connection connection.InitialCatalog = @"SENGroup25DB"; //the inital catalog of the connection connection.IntegratedSecurity = true; //the integrated security of the connection createDataHandler = new CreateHandler(connection.ToString()); deleteDataHandler = new DeleteHandler(connection.ToString()); readDataHandler = new ReadHandler(connection.ToString()); updateDataHandler = new UpdateHandler(connection.ToString()); }
/// <summary> /// Поиск именованных групп в тексте с помощью регулярного выражения /// </summary> /// <param name="regex">Регулярное выражение</param> /// <param name="groupname">Имя группы</param> /// <param name="text">Текст</param> /// <param name="handler">Делегат вызываемый при обраружении соответствия</param> /// <param name="state">Дополнительные параметры</param> private void Read(string regex, string groupname, string text, ReadHandler handler, object state) { Regex reg = new Regex(regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); Match m = reg.Match(text); while (m.Success) { handler.Invoke(m.Groups[groupname].Value, m.Index, state); m = m.NextMatch(); } }
void initalCategories() { Cate[] cateList = ReadHandler.readCategories(); for (int i = 0; i < 9; i++) { CategoryButton cateBtn = categoryContainer.transform.GetChild(i).GetComponent <CategoryButton>(); Cate cate = cateList[i]; Song[] songList = ReadHandler.readSongs(cate.ID); cateBtn.initial(cate.ID, cate.name, songList); } }
public void readCates() { Cate[] cateList = ReadHandler.readCategories(); for (int i = 0; i < 9; i++) { CategoryManager cateMng = categoryContainer.transform.GetChild(i).GetComponent <CategoryManager>(); Cate cate = cateList[i]; cateMng.setID(cate.ID); cateMng.setName(cate.name); cateMng.setToggle(cate.enabled); } }
public AsynchronousReader(ConsoleHandler consoleHandler, ReadHandler readHandler, StreamReader stream) { ConsoleHandler = consoleHandler; ReadDelegate = readHandler; Stream = stream; Buffer = new byte[ReadSize]; Callback = new AsyncCallback(ReadCallback); CloseEvent = new AutoResetEvent(false); Read(); }
public MainLogic(Logger LogManager) { autodromeStreams = new Dictionary <ulong, StreamInfo>(); navigationStreams = new List <StreamInfo>(); applicationStreams = new List <StreamInfo>(); output_buffer = new byte[3000]; acceptHandler = accept; errorHandler = error; readHandler = read; //availableHandler = new EventHandler(availabilityTimer_Tick); this.LogManager = LogManager; }
public void readSongs(string cateID, string cateName) { changeToSongTab(); songContainer.name = cateID; cateTitle.text = cateName; Song[] songList = ReadHandler.readSongs(cateID); for (int i = 0; i < 9; i++) { SongManager songMng = songContainer.transform.GetChild(i).GetComponent <SongManager>(); Song song = songList[i]; songMng.setName(song.name); songMng.setFileName(song.file); songMng.setToggle(song.enabled); } }
public void readLyrics(string songName) { foreach (Transform child in lyricsContainer.transform) { GameObject.Destroy(child.gameObject); } changeToLyricsTab(); lyricsContainer.name = songName; List <Lyrics> lyricsList = ReadHandler.readLyrics(songName); foreach (Lyrics lyr in lyricsList) { createLyricsRaw(lyr); } if (lyricsList.Count == 0) { addEmptyLyricsRaw(); } }
private Object handleStruct(Object tag, int fields) { ReadHandler h = Fns.lookup <object, ReadHandler>(handlerLookup, tag); if (h == null) { if (standardExtensionHandlers.ContainsKey(tag)) { h = standardExtensionHandlers[tag]; } } if (h == null) { return(new TaggedObject(tag, readObjects(fields))); } else { return(h.read(this, tag, fields)); } }
protected abstract void Read(ReadHandler readHandler);
/// <summary> /// Sets a callback for read requests. /// </summary> /// <param name="handler">The read request handler callback function</param> /// <param name="parameter">user provided parameter that is passed to the callback</param> public void SetReadHandler(ReadHandler handler, object parameter) { this.readHandler = handler; this.readHandlerParameter = parameter; }
public FrmScanningNew(ReadHandler theHandler) { InitializeComponent(); MyHandler = theHandler; panel1.Visible = false; }
public frmMainRibbon() { InitializeComponent(); adminReady = true; theReadHandler = new ReadHandler(ReadScannedInLearners); }
public Task <ResultOf <ReadResult> > Get([FromQuery] bool error = false) => ReadHandler.Handle(error);
public void BindReadHandler(ReadHandler handler) { readHandler = handler; }
public void BindReadHandler(ReadHandler handler) { AdvancedNamingServiceLayer.Instance.BindReadHandler(handler); }
public void SetAsyncIOInterface(ReadHandler EndRead) { m_serverPrivate.EndRead = EndRead; }
// Bind handlers for incoming messages public void BindReadHandler(ReadHandler handler) { SimpleGrpcMessageLayer.Instance.BindReadHandler(handler); }
public void SetUp() { sut = new ReadHandler(); }
/// <summary> /// Поиск именованных групп в тексте с помощью регулярного выражения /// </summary> /// <param name="regex">Регулярное выражение</param> /// <param name="groupname">Имя группы</param> /// <param name="text">Текст</param> /// <param name="handler">Делегат вызываемый при обраружении соответствия</param> /// <param name="state">Дополнительные параметры</param> private void Read(string regex, string groupname, string text, ReadHandler handler, object state) { Regex reg = new Regex(regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); Match m = reg.Match(text); while (m.Success) { handler.Invoke(m.Groups[groupname].Value, m.Index, state); m = m.NextMatch(); } }
public void BindReadHandler(ReadHandler handler) { incomingDispatcher.BindReadHandler(handler); }
// Bind handlers for incoming messages public void BindReadHandler(ReadHandler handler) { SimpleNamingServiceLayer.Instance.BindReadHandler(handler); }
// Bind handlers for incoming messages public void BindReadHandler(ReadHandler handler) { AdvancedGrpcMessageLayer.Instance.BindReadHandler(handler); }
public InputReader(Stream stream, ReadHandler handler, int bufferSize = 2048) { this.stream = stream; this.handler = handler; this.bufferSize = bufferSize; }