public void LabelledCheckBoxFor(Expression <Func <TModel, bool> > expression, IDictionary <string, object> htmlAttributes) { var builder = new TagBuilder("label"); builder.AddCssClass("checkbox"); builder.InnerHtml = string.Concat( HtmHelper.CheckBoxFor(expression, htmlAttributes).ToString(), ExpressionHelper.GetExpressionText(expression)); TxtWriter.Write(builder.ToString()); }
public void Do() { while (true) { try { string configFilePath = IOExtension.GetBaesDir() + @"\Settings.Json"; List <Settings> sets = TxtReader.ReadToModel <Settings>(new JsonReaderSettings() { FilePath = configFilePath, Encoding = encoding }); bool hasRun = false; if (sets != null) { sets.ForEach(set => { try { if (!set.CanDo()) { return; } ServicesBase sb = new ServicesBase(); MethodInfo m = sb.AutoService.GetType().GetMethod(set.MethodName); if (m == null) { throw new Exception($"找不到方法{set.MethodName}"); } m.Invoke(sb.AutoService, null); set.LastRunTime = DateTime.Now; Log.Info($"已执行{set.Name}"); hasRun = true; } catch (Exception ex) { Log.Error($"执行{set.Name}异常", ex.InnerMessage()); } }); } if (hasRun) { TxtWriter.Write(configFilePath, sets.ToJson(true), encoding); } } catch (Exception ex) { Log.Error("服务异常", ex.InnerMessage()); } finally { Thread.Sleep(SleepSecond * 1000); } } }
private void PressConfirm() { this.main.SwitchToGameView(); string combineCharacterStats = $"{Name},{Type},{Description},{Level},{HP},{XP},{Strength},{Agility},{Intelligence},{Image}"; TxtWriter characterWriter = new TxtWriter(combineCharacterStats); characterWriter.WriteCharacters(); this.main.LoadCharacterFromFile(); }
static void WriteResult() { ResultWriter resultWriter = new ResultWriter(); XmlSerializer xmlSerializer = new XmlSerializer(); JsonSerializer jsonSerializer = new JsonSerializer(); TxtWriter txtWriter = new TxtWriter(); TraceResult result = tracer.GetTraceResult(); resultWriter.ResultInConsole(txtWriter, result); resultWriter.ResultInFile(txtWriter, result, "result"); resultWriter.ResultInFile(jsonSerializer, result, "result"); resultWriter.ResultInFile(xmlSerializer, result, "result"); }
public void WriteMatrixToFileAsText() { TxtWriter txtWriter = new TxtWriter(_gz2DlzEncoderFacade.InputFilePath + Constants.IntermediaryFileExtension); txtWriter.Write(WorkImage.GetLength(1) + Constants.Separator.ToString()); txtWriter.Write(WorkImage.GetLength(0) + Constants.Separator.ToString()); txtWriter.Write(Environment.NewLine); txtWriter.WriteMatchFlagToFile(IsMatchFound); txtWriter.WriteMatchLocationToFile(MatchLocation); txtWriter.WriteMatchDimensionsToFile(MatchDimension); txtWriter.WriteMatrixToFile(Residual); txtWriter.WriteMatrixToFile(_gz2DlzEncoderFacade.AbstractPredictor.PredictionError); }
public void ResultInFile_With_Txt_Create_Right_File() { byte[] factHash, expectedHash; TxtWriter txtWriter = new TxtWriter(); MD5CryptoServiceProvider mD5 = new MD5CryptoServiceProvider(); Stream stream = new FileStream("test.txt", FileMode.Open, FileAccess.Read); expectedHash = mD5.ComputeHash(stream); stream.Close(); resultWriter.ResultInFile(txtWriter, traceResult, "factres"); stream = new FileStream("factres.txt", FileMode.Open, FileAccess.Read); factHash = mD5.ComputeHash(stream); stream.Close(); File.Delete("factres.txt"); if (!expectedHash.SequenceEqual(factHash)) { Assert.Fail("Created file is wrong"); } }
private void SaveClick(object sender, RoutedEventArgs e) { int begin = int.Parse(BeginField.Text); int end = int.Parse(EndField.Text); if (begin < 0) { begin = 0; } if (begin >= this.currentSignal.SamplesCount) { begin = this.currentSignal.SamplesCount - 1; } if (end < begin) { end = begin; } if (end >= this.currentSignal.SamplesCount) { end = this.currentSignal.SamplesCount - 1; } BeginField.Text = begin.ToString(); EndField.Text = end.ToString(); var signalToSave = new Signal(this.currentSignal.fileName); signalToSave.StartDateTime = this.currentSignal.StartDateTime; signalToSave.SamplingFrq = this.currentSignal.SamplingFrq; for (int i = 0; i < this.currentSignal.channels.Count; i++) { if (checkers[i].IsChecked == true) { signalToSave.channels.Add(this.currentSignal.channels[i]); } } Logger.Info($"Tried to save signal {signalToSave}"); if (signalToSave.channels.Count == 0) { MessageBox.Show("Не выбрано ни одного канала", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var saveDialog = new SaveFileDialog(); saveDialog.Filter = "txt files (.txt)|*.txt|wave files (*.wav;*.wave)|*.wav;*.wave|dat files (*.dat)|*.dat"; if (saveDialog.ShowDialog() == true) { IWriter writer; switch (Path.GetExtension(saveDialog.FileName)) { case ".txt": writer = new TxtWriter(); break; case ".wav": case ".wave": writer = new WaveWriter(); break; case ".dat": writer = new DatWriter(); break; default: throw new NotImplementedException(); } File.WriteAllBytes(saveDialog.FileName, writer.TryWrite(SignalToFileInfo(signalToSave, begin, end))); } }