IDimensions.cs 1.3 KB

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