protected override List <ITextElementFormatter> ColumnHeaderTextElements() { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create("ID", ElementWidths[0])); elements.Add(FormatterFactory.Create("DESCRIPTION", ElementWidths[1])); elements.Add(FormatterFactory.Create("WEIGHT", ElementWidths[2])); return(elements); }
protected override List <ITextElementFormatter> RowTextElements(Product item) { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create(item.ProductId.ToString(), ElementWidths[0])); elements.Add(FormatterFactory.Create(item.Description, ElementWidths[1])); elements.Add(FormatterFactory.Create($"{item.Weight:F3}", ElementWidths[2])); return(elements); }
protected override List <ITextElementFormatter> ColumnHeaderTextElements() { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create("MATERIAL", ElementWidths[0])); elements.Add(FormatterFactory.Create("WIDTH x HEIGHT x DEPTH", ElementWidths[1])); elements.Add(FormatterFactory.Create("MAX. WEIGHT", ElementWidths[2])); return(elements); }
protected override List <ITextElementFormatter> RowTextElements(ShippingBox item) { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create(item.Material, ElementWidths[0])); elements.Add(FormatterFactory.Create($"{item.Width} x {item.Height} x {item.Depth}", ElementWidths[1])); elements.Add(FormatterFactory.Create($"(Max. {item.MaxWeight:F3} kgs.)", ElementWidths[2])); return(elements); }
protected override List <ITextElementFormatter> RowTextElements(Customer item) { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create(item.CustomerId.ToString(), ElementWidths[0])); elements.Add(FormatterFactory.Create(item.Name, ElementWidths[1])); elements.Add(FormatterFactory.Create(item.Address, ElementWidths[2])); elements.Add(FormatterFactory.Create(item.ZipCode.ToString(), ElementWidths[3])); return(elements); }
protected override List <ITextElementFormatter> ColumnHeaderTextElements() { List <ITextElementFormatter> elements = new List <ITextElementFormatter>(); elements.Add(FormatterFactory.Create("ID", ElementWidths[0])); elements.Add(FormatterFactory.Create("NAME", ElementWidths[1])); elements.Add(FormatterFactory.Create("ADDRESS", ElementWidths[2])); elements.Add(FormatterFactory.Create("ZIPCODE", ElementWidths[3])); return(elements); }
public void Create_CreatedFormatters_AreNotReused() { // Arrange var target = new FormatterFactory(new FormattingContext(new XamlFormatterOptions())); foreach (FragmentType type in Enum.GetValues(typeof(FragmentType))) { try { // Act var formatter1 = target.Create(type); var formatter2 = target.Create(type); // Assert Assert.AreNotSame(formatter1, formatter2); } catch (Exception) { Trace.WriteLine($"Failed to create formatter for type '{type}'"); throw; } } }
public Task RunAsync() { var date = this.VerbOptions.Date.GetValueOrDefault(DateTime.Today); var epoch = (Epoch)date; var version = this.VerbOptions.Number ?? new Version("1.0.0.0"); var level = this.VerbOptions.VersionLevel; Version result = null; if (level == VersionLevel.Revision) { result = new Version(version.Major, version.Minor, version.Build, epoch); } else if (level == VersionLevel.Build) { result = new Version(version.Major, version.Minor, version.Build + 1, epoch); } else if (level == VersionLevel.Minor) { result = new Version(version.Major, version.Minor + 1, 0, epoch); } else if (level == VersionLevel.Major) { result = new Version(version.Major + 1, 0, 0, epoch); } var formatter = FormatterFactory.Create( this.VerbOptions.Output.GetValueOrDefault(OutputType.Json), this.VerbOptions.Query); return(formatter.WriteAsync(Console.Out, new { Date = date.ToString("yyyy-MM-dd"), Year = date.ToString("yyyy"), Month = date.ToString("MM"), Day = date.ToString("dd"), Number = result.ToString(), Major = result.Major, Minor = result.Minor, Build = result.Build, Revision = result.Revision })); }
/// <summary> /// 財務数値、指標などの値を取得します。 /// </summary> /// <param name="ticker">銘柄コード</param> /// <param name="parameter1">パラメタ1</param> /// <param name="parameter2">パラメタ2</param> /// <param name="propertyName">項目名</param> /// <param name="isRawValue">rawデータフラグ</param> /// <param name="isPostfixUnit">単位フラグ</param> /// <returns>値</returns> public string GetValue(string ticker, string parameter1, string parameter2, string propertyName, bool isRawValue = false, bool isPostfixUnit = false) { var aggregation = GetAggregation(ticker, parameter1, parameter2, propertyName); string rawValue = aggregation.GetValue(propertyName); if (isRawValue) { return(rawValue); } var description = aggregation.GetDescription(propertyName); var formatter = FormatterFactory.Create(description); string formattedValue = formatter.Format(rawValue, description); if (isPostfixUnit) { formattedValue += description.Unit; } return(formattedValue); }
public void Create_AllFragmentTypes_FormatterCreated() { // Arrange var target = new FormatterFactory(new FormattingContext(new XamlFormatterOptions())); foreach (FragmentType type in Enum.GetValues(typeof(FragmentType))) { try { // Act var formatter = target.Create(type); // Assert Assert.IsNotNull(formatter); } catch (Exception) { Trace.WriteLine($"Failed to create formatter for type '{type}'"); throw; } } }
public Task RunAsync() { Epoch epoch; if (this.VerbOptions.RevisionDate.HasValue) { epoch = (Epoch)this.VerbOptions.RevisionDate; } else if (this.VerbOptions.RevisionNumber != 0) { epoch = (Epoch)this.VerbOptions.RevisionNumber; } else { epoch = (Epoch)DateTime.Today; } var formatter = FormatterFactory.Create( this.VerbOptions.Output.GetValueOrDefault(OutputType.Json), this.VerbOptions.Query); return(formatter.WriteAsync(Console.Out, epoch)); }
private IFormatter CreateFormatter(string name, string label, string unit) { PropertyDescrption description = new PropertyDescrption(name, label, unit); return(FormatterFactory.Create(description)); }
private void WriteNewSheet() { string ticker = textTicker.Text; string from = textFrom.Text; string to = textTo.Text; var quarters = GetSortedQuarters(ticker, from, to); if (quarters.Count == 0) { MessageBox.Show("条件に当てはまる財務データがありませんでした。", "CSV出力", MessageBoxButtons.OK); return; } // create new sheet Microsoft.Office.Interop.Excel.Worksheet worksheet; try { worksheet = BuffettCode.Globals.ThisAddIn.Application.Worksheets.Add(); } catch (Exception) { MessageBox.Show("新しいシートの作成に失敗しました。", "CSV出力", MessageBoxButtons.OK); return; } // write header int row = 1; int col = 1; worksheet.Cells[col, row++] = "キー"; worksheet.Cells[col, row++] = "項目名"; worksheet.Cells[col, row++] = "単位"; foreach (var quarter in quarters) { worksheet.Cells[col, row++] = quarter.FiscalYear + "Q" + quarter.FiscalQuarter; } // write values var propertyNames = CSVGenerator.GetPropertyNames(quarters[0]); foreach (var propertyName in propertyNames) { row = 1; col++; var description = quarters[0].GetDescription(propertyName); worksheet.Cells[col, row++] = propertyName; worksheet.Cells[col, row++] = description.Label; worksheet.Cells[col, row++] = description.Unit; foreach (var quarter in quarters) { var rawValue = quarter.GetValue(propertyName); var formatter = FormatterFactory.Create(description); string formattedValue = formatter.Format(rawValue, description); worksheet.Cells[col, row++] = formattedValue; } } MessageBox.Show("新しいシートを作成しました。", "CSV出力", MessageBoxButtons.OK); DialogResult = DialogResult.OK; Close(); }