private static void AssertRoundtripInvariant(MetricRange a, MetricRange b, MetricUnit metricUnit) { var c = HostEnvironmentInfo.MainCultureInfo; a.GetMinMaxString(metricUnit, out var aMin, out var aMax); b.GetMinMaxString(metricUnit, out var bMin, out var bMax); var a2 = MetricValueHelpers.CreateMetricRange( double.Parse(aMin, c), double.Parse(aMax, c), metricUnit); var b2 = MetricValueHelpers.CreateMetricRange( double.Parse(bMin, c), double.Parse(bMax, c), metricUnit); IsTrue(a.ContainsWithRounding(a2, metricUnit)); IsTrue(a2.ContainsWithRounding(a, metricUnit)); IsTrue(b.ContainsWithRounding(b2, metricUnit)); IsTrue(b2.ContainsWithRounding(b, metricUnit)); if (a.ContainsWithRounding(b, metricUnit)) { IsTrue(a2.ContainsWithRounding(b2, metricUnit)); } }
public Meal(string initialName, decimal initialPrice, int initialCalories, int initialQuantityPerServing, MetricUnit initialmetricUnit, int initialTimeToPrepare,bool initialIsVegan) : base(initialName, initialPrice, initialCalories, initialQuantityPerServing, initialmetricUnit, initialTimeToPrepare) { this.isVegan = initialIsVegan; }
internal Metric(string id, string type, LocalizableString localizedName, MetricUnit unit, IEnumerable <TimeSeriesElement> timeseries) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } if (localizedName == null) { throw new ArgumentNullException(nameof(localizedName)); } if (timeseries == null) { throw new ArgumentNullException(nameof(timeseries)); } Id = id; Type = type; LocalizedName = localizedName; Unit = unit; Timeseries = timeseries.ToList(); }
public async Task SendMetricData(ILogger logger, string message) { var metricDataValue = new Metric(); metricDataValue.series = new List <MetricUnit>(); var random = new Random(); var rvalue = random.Next(0, 600); var munit = new MetricUnit { host = "www.asb.co.nz", metric = "asb_payment_batch_total_success_processed", type = "count", interval = 20, points = new List <long[]>() { new long[] { DateTime.Now.ToUnixTime(), Convert.ToInt64(rvalue) } }, tags = message }; metricDataValue.series.Add(munit); string postMetricData = JsonConvert.SerializeObject(metricDataValue); var response = await AppConstant.DATADOG_METRIC_SERIES_POST_URL.PostJsonAsync(metricDataValue); logger.LogInformation($"Provider: {this.GetType().Name}): {postMetricData}, response: {response}"); }
internal Metric(string id, string type, LocalizableString localizedName, MetricUnit unit, IReadOnlyList <TimeSeriesElement> timeseries) { Id = id; Type = type; LocalizedName = localizedName; Unit = unit; Timeseries = timeseries; }
public Recipe(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare) { TimeToPrepare = timeToPrepare; Unit = unit; QuantityPerServing = quantityPerServing; Calories = calories; Price = price; Name = name; }
public void GeneralSITest() { var actual = MetricUnit.Kilo <Metre>(100); var expected = new Length <double>(); Assert.AreEqual(expected, actual); }
public Recipe(string name, decimal price, int calories, int quantity, MetricUnit unit, int time) { this.Name = name; this.Price = price; this.Calories = calories; this.QuantityPerServing = quantity; this.Unit = unit; this.TimeToPrepare = time; }
protected Recipe(string name, int quantityPerServing, decimal price, int calories, MetricUnit unit, int timeToPrepare) { this.Name = name; this.QuantityPerServing = quantityPerServing; this.Price = price; this.Calories = calories; this.Unit = unit; this.TimeToPrepare = timeToPrepare; }
public Recipe(string initialName, decimal initialPrice, int initialCalories, int initialQuantityPerServing, MetricUnit initialmetricUnit, int initialTimeToPrepare) { this.Name = initialName; this.Price = initialPrice; this.Calories = initialCalories; this.QuantityPerServing = initialQuantityPerServing; this.metricUnit = initialmetricUnit; this.TimeToPrepare = initialTimeToPrepare; }
protected Recipe(string name, decimal price, int calories, int quantityPerServing, int timeToPrepare, MetricUnit unit) { this.Name = name; this.Price = price; this.Calories = calories; this.QuantityPerServing = quantityPerServing; this.TimeToPrepare = timeToPrepare; this.Unit = unit; }
/// <summary> /// New Metric Weight measurement from <paramref name="value"/> in <paramref name="unit"/> /// </summary> /// <param name="value"></param> /// <param name="unit"></param> public MetricWeight(double value, MetricUnit unit) { _picograms = _nanograms = _micrograms = _milligrams = _grams = _kilograms = _megagrams = 0; switch (unit) { case MetricUnit.Grams: { BaseValue = value; break; } case MetricUnit.Kilogram: { Kilograms = value; break; } case MetricUnit.Megagram: case MetricUnit.Tonne: { Megagrams = value; break; } case MetricUnit.Microgram: { Micrograms = value; break; } case MetricUnit.Milligram: { Milligrams = value; break; } case MetricUnit.Nanogram: { Nanograms = value; break; } case MetricUnit.Picogram: { Picograms = value; break; } default: { throw new UnknownConversionException($"IoT Library Exception! Someone forgot to add '{unit.ToString()}' to the constructor!"); } } }
public void CanGetMetricQueryResult() { var metadata = new Dictionary <string, string> { { "metadatatest1", "metadatatest2" } }; var metricValue = MonitorQueryModelFactory.MetricValue(new DateTimeOffset(new DateTime(10))); var metricValueList = new List <MetricValue>() { metricValue }; MetricTimeSeriesElement metricTimeSeriesElement = MonitorQueryModelFactory.MetricTimeSeriesElement(metadata, metricValueList); Assert.IsNotNull(metricTimeSeriesElement); Assert.AreEqual(1, metricTimeSeriesElement.Metadata.Count); var firstElement = metricTimeSeriesElement.Metadata.First(); Assert.AreEqual("metadatatest1", firstElement.Key); Assert.AreEqual("metadatatest2", firstElement.Value); Assert.AreEqual(1, metricTimeSeriesElement.Values.Count); Assert.AreEqual(new DateTimeOffset(new DateTime(10)), metricTimeSeriesElement.Values[0].TimeStamp); IEnumerable <MetricTimeSeriesElement> metricTimeSeriesElements = new[] { metricTimeSeriesElement }; MetricUnit metricUnit = new MetricUnit("test"); Assert.IsNotNull(metricUnit); Assert.AreEqual("test", metricUnit.ToString()); MetricResult metricResult = MonitorQueryModelFactory.MetricResult("https://management.azure.gov", "type", "name", metricUnit, metricTimeSeriesElements); Assert.IsNotNull(metricResult); Assert.AreEqual(null, metricResult.Description); Assert.AreEqual(null, metricResult.Error.Code); Assert.AreEqual(null, metricResult.Error.Message); Assert.AreEqual("https://management.azure.gov", metricResult.Id); Assert.AreEqual("name", metricResult.Name); Assert.AreEqual("type", metricResult.ResourceType); Assert.AreEqual(1, metricResult.TimeSeries.Count); Assert.AreEqual("test", metricResult.Unit.ToString()); IEnumerable <MetricResult> metricResults = new[] { metricResult }; MetricsQueryResult metricsQueryResult = MonitorQueryModelFactory.MetricsQueryResult(null, TimeSpan.FromMinutes(3).ToString(), null, "namespace", "eastus", metricResults.ToList()); Assert.AreEqual(null, metricsQueryResult.Cost); Assert.AreEqual(null, metricsQueryResult.Granularity); Assert.AreEqual(1, metricsQueryResult.Metrics.Count); Assert.AreEqual(null, metricsQueryResult.Metrics[0].Description); Assert.AreEqual(null, metricsQueryResult.Metrics[0].Error.Code); Assert.AreEqual(null, metricsQueryResult.Metrics[0].Error.Message); Assert.AreEqual("https://management.azure.gov", metricsQueryResult.Metrics[0].Id); Assert.AreEqual("name", metricsQueryResult.Metrics[0].Name); Assert.AreEqual("type", metricsQueryResult.Metrics[0].ResourceType); Assert.AreEqual("namespace", metricsQueryResult.Namespace); Assert.AreEqual("eastus", metricsQueryResult.ResourceRegion); Assert.IsNotNull(metricsQueryResult); }
/// <summary> ///This method adds on the last with the addition of setting the optional parameter countUnits. /// The unit names may be mixed case and must consist strictly /// of alphabetical characters as well as the _, % and / symbols. Case is preserved. /// Recommendation: Use uncapitalized words, spelled out in full. For example, use second not Sec. /// While there are a few predefined units please feel free to add your own by typecasting an NSString. /// </summary> /// <param name="name">the metric name</param> /// <param name="category">a descriptive category</param> /// <param name="value">the value to record.</param> /// <param name="valueUnits">the units of value</param> /// <param name="countUnits">represents the unit of the metric</param> static public void RecordMetricWithName(string name, string category, double value, MetricUnit valueUnits, MetricUnit countUnits) { if (validatePluginImpl()) { instance.agentInstance.recordMetricWithName(name, category, value, valueUnits, countUnits); } }
/// <summary> /// Initializes a new instance of the MetricDefinition class. /// </summary> /// <param name="name">The metric name</param> /// <param name="unit">The metric unit. Possible values include: /// 'Bytes', 'BytesPerSecond', 'Count', 'CountPerSecond', 'Percent', /// 'Seconds'</param> /// <param name="primaryAggregationType">The metric aggregation type. /// Possible values include: 'Average', 'Last', 'Maximum', 'Minimum', /// 'None', 'Total'</param> /// <param name="resourceId">The metric source id</param> /// <param name="metricAvailabilities">The available metric /// granularities</param> /// <param name="dimensions">The supported dimensions</param> /// <param name="type">The metric definition type</param> public MetricDefinition(MetricName name, MetricUnit unit, MetricAggregationType primaryAggregationType, string resourceId, IList <MetricAvailablity> metricAvailabilities, IList <MetricDimension> dimensions, string type) { Name = name; Unit = unit; PrimaryAggregationType = primaryAggregationType; ResourceId = resourceId; MetricAvailabilities = metricAvailabilities; Dimensions = dimensions; Type = type; CustomInit(); }
/// <summary> /// Convert the given bytes to <see cref="MetricUnit"/> /// </summary> /// <param name="bytes">Value in bytes to be converted</param> /// <param name="type">Unit to convert to</param> /// <returns>Converted bytes</returns> public static double ConvertToUnit(double bytes, MetricUnit type) { // var rg = new[] { "k","M","G","T","P","E","Z","Y"}; // var pow = rg.ToList().IndexOf(type) +1; int pow = (int)type; double v = bytes / Math.Pow(MAGNITUDE, pow); return(v); }
/// <summary>Initializes a new instance of the <see cref="CompetitionMetricValue"/> class.</summary> /// <param name="metric">The metric information.</param> /// <param name="valuesRange">The metric values range.</param> /// <param name="displayMetricUnit">The preferred metric unit for the values range.</param> public CompetitionMetricValue( [NotNull] MetricInfo metric, MetricRange valuesRange, [NotNull] MetricUnit displayMetricUnit) { Code.NotNull(metric, nameof(metric)); Code.NotNull(displayMetricUnit, nameof(displayMetricUnit)); Metric = metric; ValuesRange = valuesRange; DisplayMetricUnit = displayMetricUnit; }
public static async Task SendMetricDataClient(ILogger logger, string message) { try { var seriesRootData = new Metric(); seriesRootData.series = new List <MetricUnit>(); var random = new Random(); var rvalue = random.Next(0, 600); var munit = new MetricUnit { host = "www.asb.co.nz", metric = "asb_payment_batch_demo", type = "rate", interval = 20, points = new List <long[]>() { new long[] { DateTime.Now.ToUnixTime(), Convert.ToInt64(rvalue) } }, tags = message }; seriesRootData.series.Add(munit); string output = JsonConvert.SerializeObject(seriesRootData); var Url = "https://api.datadoghq.com/api/v1/series?api_key=75cb6c3734c6525a829f8e0ca18ceaac"; logger.LogInformation($"Output from json (httpclient v1): {output}"); HttpContent httpContent = new StringContent(output, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var result = await client.PostAsync(Url, httpContent); HttpContent responseContent = result.Content; // Get the stream of the content. using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync())) { // Write the output. logger.LogInformation("Final response output" + await reader.ReadToEndAsync()); } } } catch (Exception ex) { var totalmessage = ex?.Message + "\n" + ex?.InnerException?.Message + "\n" + ex?.StackTrace; logger.LogInformation($"Error.v10x : {totalmessage} "); } }
/// <summary> /// /// </summary> /// <param name="dtPin"></param> /// <param name="sckPin"></param> /// <param name="calibrationWeightSystem">Determines which calibration unit will be used</param> /// <param name="calibrationImperialUnit">Only needs entered if weight system is Imperial</param> /// <param name="calibrationMetricUnit">Only needs entered if weight system is Metric</param> /// <param name="pinNumberingScheme"></param> /// <param name="gain"></param> /// <param name="msb">Boolean indicating that the HX711 outputs the most significant bit first</param> public HX711Settings(int dtPin, int sckPin, WeightSystem calibrationWeightSystem = WeightSystem.Metric, ImperialUnit calibrationImperialUnit = ImperialUnit.Pounds, MetricUnit calibrationMetricUnit = MetricUnit.Grams, double calibrationValue = 0, PinNumberingScheme pinNumberingScheme = PinNumberingScheme.Logical, bool msb = true) { DTPin = dtPin; SCKPin = sckPin; MSB = msb; CalibrationWeightSystem = calibrationWeightSystem; CalibrationImperialUnit = calibrationImperialUnit; CalibrationMetricUnit = calibrationMetricUnit; CalibrationValue = calibrationValue; PinNumberingScheme = pinNumberingScheme; }
/// <summary> /// Initializes a new instance of the Metrics class. /// </summary> /// <param name="resourceId">The id of metric source</param> /// <param name="startTime">The metric start time</param> /// <param name="endTime">The metric end time</param> /// <param name="timeGrain">The time grain, time grain indicates /// frequency of the metric data</param> /// <param name="primaryAggregation">The metric aggregation type. /// Possible values include: 'Average', 'Last', 'Maximum', 'Minimum', /// 'None', 'Total'</param> /// <param name="name">The name of the metrics</param> /// <param name="dimensions">The Metric dimension which indicates the /// source of the metric</param> /// <param name="unit">The unit of the metric data. Possible values /// include: 'Bytes', 'BytesPerSecond', 'Count', 'CountPerSecond', /// 'Percent', 'Seconds'</param> /// <param name="type">The Type of the metric data</param> /// <param name="values">The metric data</param> public Metrics(string resourceId, System.DateTime startTime, System.DateTime endTime, string timeGrain, MetricAggregationType primaryAggregation, MetricName name, IList <MetricDimension> dimensions, MetricUnit unit, string type, IList <MetricData> values) { ResourceId = resourceId; StartTime = startTime; EndTime = endTime; TimeGrain = timeGrain; PrimaryAggregation = primaryAggregation; Name = name; Dimensions = dimensions; Unit = unit; Type = type; Values = values; CustomInit(); }
public void AddDifferentUnitsAndSameDimension() { Mass <double> on = 1; on.Unit = new Ounce(); var l = MetricUnit.None <Gram>(0); var g = on + l; Assert.AreEqual(g.Value, 1); }
public void UnitMassAddTest() { var l1 = MetricUnit.Kilo <Gram>(2); var l2 = MetricUnit.None <Gram>(500); var l = l1 + l2; Assert.AreEqual <double>(2.5, l.Value); var lr = l2 + l1; Assert.AreEqual <double>(2500, lr.Value); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] MetricUnit metricUnit) { try { Context.MetricUnits.Add(new MetricUnit() { Name = metricUnit.Name }); Context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, true)); } catch (Exception ex) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ExceptionMessageHelper.GetErrorMessage(ex))); } }
public static async Task SendMetricData(ILogger logger, string message) { try { var seriesRootData = new Metric(); seriesRootData.series = new List <MetricUnit>(); var random = new Random(); var rvalue = random.Next(0, 600); var munit = new MetricUnit { host = "www.asb.co.nz", metric = "asb_payment_batch_demo", type = "count", interval = 20, //points = new List<Point[]>() { // new Point[] { new Point(DateTime.Now.ToUnixTime(), 320)}, //}, points = new List <long[]>() { new long[] { DateTime.Now.ToUnixTime(), Convert.ToInt64(rvalue) } }, tags = message }; seriesRootData.series.Add(munit); string output = JsonConvert.SerializeObject(seriesRootData); //var data = "{ \"series\" : [{\"metric\":\"asb_payment_batch_demo\", \"points\":[[1571611333, 555]], \"type\":\"rate\", \"interval\": 20, \"host\":\"test.example.com\", \"tags\":[\"environment:test\"]}]}"; logger.LogInformation($"Output from json (unserialized data:retest): {output}"); var response = await "https://api.datadoghq.com/api/v1/series?api_key=75cb6c3734c6525a829f8e0ca18ceaac".PostJsonAsync(seriesRootData); // logger.LogInformation($"AppDataDogMetricData:v1: {response.StatusCode} : {response}"); } catch (Exception ex) { var totalmessage = ex?.Message + "\n" + ex?.InnerException?.Message + "\n" + ex?.StackTrace; logger.LogInformation($"Error.v6 : {totalmessage} "); } }
protected Recipe(string name, decimal price, int calories, int quantity, MetricUnit unit, int time) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("The name is required."); } if (price < 0 || calories < 0 || quantity < 0 || time < 0) { throw new InvalidOperationException("The <parameter> must be positive."); } this.name = name; this.price = price; this.calories = calories; this.quantityPerServing = quantity; this.unit = unit; this.timeToPrepare = time; }
public IHttpActionResult CreateUnit([FromBody] JObject jsonResult) { dynamic jObjReturn = new JObject(); string unit = jsonResult["unitName"].ToString(); CoachItEntities _db = new CoachItEntities(); MetricUnit metricUnit = _db.MetricUnits.FirstOrDefault(x => x.Unit == unit); if (metricUnit == null) { metricUnit = new MetricUnit() { Unit = unit }; _db.MetricUnits.Add(metricUnit); _db.SaveChanges(); var metricUnitReturn = (from s in _db.MetricUnits where s.Id == metricUnit.Id select new { Id = s.Id, Unit = s.Unit }).ToList().FirstOrDefault(); _db.Dispose(); jObjReturn.status = "OK"; jObjReturn.result = JsonConvert.SerializeObject(metricUnitReturn); } else { _db.Dispose(); jObjReturn.status = "FAILED"; jObjReturn.result = $"Unit '{unit}' already exist!"; } return(Ok(jObjReturn)); }
/// <summary> /// Initializes a new instance of the <see cref="Recipe"/> class. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="price"> /// The price. /// </param> /// <param name="calories"> /// The calories. /// </param> /// <param name="quantity"> /// The quantity. /// </param> /// <param name="unit"> /// The unit. /// </param> /// <param name="time"> /// The time. /// </param> /// <exception cref="ArgumentException"> /// </exception> protected Recipe(string name, decimal price, int calories, int quantity, MetricUnit unit, int time) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("The name is required."); } if (price < 0 || calories < 0 || quantity < 0 || time < 0) { throw new InvalidOperationException("The <parameter> must be positive."); } this.name = name; this.price = price; this.calories = calories; this.quantityPerServing = quantity; this.unit = unit; this.timeToPrepare = time; }
internal static Metric DeserializeMetric(JsonElement element) { string id = default; string type = default; LocalizableString name = default; MetricUnit unit = default; IReadOnlyList <TimeSeriesElement> timeseries = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = LocalizableString.DeserializeLocalizableString(property.Value); continue; } if (property.NameEquals("unit")) { unit = property.Value.GetString().ToMetricUnit(); continue; } if (property.NameEquals("timeseries")) { List <TimeSeriesElement> array = new List <TimeSeriesElement>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(TimeSeriesElement.DeserializeTimeSeriesElement(item)); } timeseries = array; continue; } } return(new Metric(id, type, name, unit, timeseries)); }
public void UpdateFor(Time <double> time) { Stopwatch sw = new Stopwatch(); var mtime = MetricUnit.Milli <Second>(0) + time; loop = true; sw.Start(); var t = Task.Factory.StartNew(() => { while (sw.ElapsedMilliseconds < mtime.Value && loop == true) { Update(); } //stop the timer. sw.Stop(); }); runningTasks.Add(t); }
// PUT api/<controller>/5 public HttpResponseMessage Put(int id, [FromBody] MetricUnit metricUnit) { try { var existingRecord = Context.MetricUnits.FirstOrDefault(mu => mu.Id == id); if (existingRecord != null) { existingRecord.Name = metricUnit.Name; Context.MetricUnits.AddOrUpdate(existingRecord); Context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, true)); } throw new Exception("Metric unit with id " + id + " not found."); } catch (Exception ex) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Conflict, ExceptionMessageHelper.GetErrorMessage(ex))); } }
internal static string ToSerializedValue(this MetricUnit value) { switch (value) { case MetricUnit.Bytes: return("Bytes"); case MetricUnit.BytesPerSecond: return("BytesPerSecond"); case MetricUnit.Count: return("Count"); case MetricUnit.CountPerSecond: return("CountPerSecond"); case MetricUnit.Percent: return("Percent"); case MetricUnit.Seconds: return("Seconds"); } return(null); }
public MainCourse(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, MainCourseType type) : base(name, price, calories, quantityPerServing, unit, timeToPrepare) { Type = (MainCourseType)Enum.Parse(typeof(MainCourseType), type.ToString()); ; }
public void PublishCounter(string id, string category, CounterTypeEnum counterType, string counter, long value, MetricUnit unit) { PublishCounters(id, category, counterType, new Dictionary <string, MetricValue>() { { counter, new MetricValue(value, unit) } }); }
public override string ToString() { var recipe = new StringBuilder(); var unit = string.Empty; switch (this.Unit) { case MetricUnit.Grams: unit = "g"; break; case MetricUnit.Milliliters: unit = "ml"; break; } recipe.AppendFormat("== {0} == {1}\r\n", this.Name, this.Price.ToString("C", CultureInfo.CreateSpecificCulture("en-US"))); recipe.AppendFormat("Per serving: {0} {1}, {2} kcal\r\n", this.QuantityPerServing, unit, this.Calories); recipe.AppendFormat("Ready in {0} minutes", this.TimeToPrepare); return recipe.ToString(); }
public MainCourse(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool isVegan, MainCourseType type) : base(name, price, calories, quantityPerServing, unit, timeToPrepare, isVegan) { this.Type = type; }
public Drink(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool isCarbonated) : base(name, price, calories, quantityPerServing, unit, timeToPrepare) { this.IsCarbonated = isCarbonated; this.Unit = MetricUnit.Milliliters; }
public Product(T entity, MetricUnit unit) { Entity = entity; _unit = unit; }
public Double In(MetricUnit unit) { return GetDistanceInMeters() * metricFactors[unit]; }
public static Distance Of(Double amount, MetricUnit unit) { return new FixedDistance(amount / metricFactors[unit]); }
public Dessert(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool isVegan, bool withSugar) : base(name, price, calories, quantityPerServing, unit, timeToPrepare, isVegan) { this.WithSugar = withSugar; }
protected Meal(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool isVegan) : base(name, price, calories, quantityPerServing, unit, timeToPrepare) { this.IsVegan = isVegan; }
public override void Draw(Graphics graphics, float pixelPerMeter) { PointF p1 = new PointF(); PointF p2 = new PointF(); // include time into the picture Time <double> TQ = (Time <double>)MetricUnit.Milli <Second>(0); // prepare for time if (Timer.IsRunning) { TQ = (Time <double>)MetricUnit.Milli <Second>(Timer.ElapsedMilliseconds); } Length <double> ActualRadius; if (radfunc != null) { ActualRadius = (Length <double>)(zm + radfunc.Invoke(TQ)); } else if (_radius.GetType().Equals(typeof(Velocity <double>))) { ActualRadius = (Length <double>)(zm + (_radius * TQ)); } else { ActualRadius = (Length <double>)(zm + _radius); } Length <double> ActualX; if (xfunc != null) { ActualX = (Length <double>)(zm + xfunc.Invoke(TQ)); } else if (_x.GetType().Equals(typeof(Velocity <double>))) { ActualX = (Length <double>)(zm + (_x * TQ)); } else { ActualX = (Length <double>)(zm + _x); } Length <double> ActualY; if (yfunc != null) { ActualY = (Length <double>)(zm + yfunc.Invoke(TQ)); } else if (_y.GetType().Equals(typeof(Velocity <double>))) { ActualY = (Length <double>)(zm + (_y * TQ)); } else { ActualY = (Length <double>)(zm + _y); } p1.X = (float)((ActualX - ActualRadius).Value * pixelPerMeter); p2.X = (float)((ActualX + ActualRadius).Value * pixelPerMeter); p1.Y = (float)((ActualY - ActualRadius).Value * pixelPerMeter); p2.Y = (float)((ActualY + ActualRadius).Value * pixelPerMeter); SizeF sf = new SizeF(p2.X - p1.X, p2.Y - p1.Y); RectangleF rc = new RectangleF(p1, sf); graphics.DrawEllipse( Pens.Blue , rc ); // start the timer after drawing the first round if (!Timer.IsRunning) { Timer.Start(); } }
public Dessert(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool withSugar) : base(name, price, calories, quantityPerServing, unit, timeToPrepare) { WithSugar = true; }
public Salad(string name, decimal price, int calories, int quantity, MetricUnit unit, int time, bool isVegan, bool containsPasta) : base(name, price, calories, quantity, unit, time, true) { this.ContainsPasta = containsPasta; }
public Salad(string name, decimal price, int calories, int quantityPerServing, MetricUnit unit, int timeToPrepare, bool isVegan, bool containsPasta) : base(name, price, calories, quantityPerServing, unit, timeToPrepare, isVegan) { this.ContainsPasta = containsPasta; }