IDimensions.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using InABox.Core;
  2. using System;
  3. namespace Comal.Classes
  4. {
  5. public interface IDimensions
  6. {
  7. IDimensionUnit Unit { get; }
  8. IDimensionUnit GetUnit();
  9. double Quantity { get; set; }
  10. double Length { get; set; }
  11. double Width { get; set; }
  12. double Height { get; set; }
  13. double Weight { get; set; }
  14. double Value { get; set; }
  15. String UnitSize { get; set; }
  16. void Set(IDimensionUnit unit, double quantity, double length, double width, double height, double weight);
  17. void CopyFrom(IDimensions source, bool observing = false);
  18. public void Calculate(object? quantity, object? length, object? width, object? height, object? weight, string? formula, string? format)
  19. {
  20. if (Dimensions.Evaluate<double>(formula, quantity, length, width, height, weight, out double value))
  21. Value = value;
  22. if (Dimensions.Evaluate<String>(format, quantity, length, width, height, weight, out string unitsize))
  23. UnitSize = unitsize;
  24. }
  25. public void CalculateValueAndUnitSize()
  26. {
  27. this.Calculate(Quantity, Length, Width, Height, Weight, Unit.Formula, Unit.Format);
  28. }
  29. }
  30. }