Example #1
0
		/// <summary>
		/// Creates a new instance of the serializer.
		/// </summary>
		/// <param name="name">The name.</param>
		/// <param name="formatterFactory">The factory that supplies fresh instances of the formatter.</param>
		/// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="formatterFactory"/> are <B>null</B> references.</exception>
		public ContextualSerializer(string/*!*/ name, FormatterFactory/*!*/ formatterFactory)
		{
			if (name == null)
				throw new ArgumentNullException("name");

			if (formatterFactory == null)
				throw new ArgumentNullException("formatterFactory");

			this.name = name;
			this.formatterFactory = formatterFactory;
		}
        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();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ChannelFactory" /> class.
        /// </summary>
        /// <param name="graphite">The graphite configuration.</param>
        /// <param name="statsd">The statsd configuration.</param>
        /// <exception cref="System.ArgumentException">Invalid configuration values.</exception>
        public ChannelFactory(IGraphiteConfiguration graphite, IStatsDConfiguration statsd)
        {
            this.formatters = new FormatterFactory();

            this.SetupPipes(graphite, statsd);
        }
Example #4
0
        public void CreateFormattersTest_DefaultTypes(Format format, Type expectedType)
        {
            IFormatter <TestEntity> sut = FormatterFactory.CreateFormatter <TestEntity>(format);

            Assert.IsType(expectedType, sut);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ChannelFactory" /> class.
        /// </summary>
        /// <param name="graphite">The graphite configuration.</param>
        /// <param name="statsd">The statsd configuration.</param>
        /// <exception cref="System.ArgumentException">Invalid configuration values.</exception>
        public ChannelFactory(IGraphiteConfiguration graphite, IStatsDConfiguration statsd)
        {
            this.formatters = new FormatterFactory();

            this.SetupPipes(graphite, statsd);
        }