protected double UnitFactor(ISpatialReference sr, esriUnits units, double referenceScale) { var pc = sr as IProjectedCoordinateSystem; if (pc == null) { return(1); } if (_unitConverter == null) { _unitConverter = new UnitConverterClass(); } double f = _unitConverter.ConvertUnits(1, esriUnits.esriMeters, units); f = f * pc.CoordinateUnit.MetersPerUnit; f = f * referenceScale; if (_unitsType == typeof(LengthUnits)) { } else if (_unitsType == typeof(AreaUnits)) { f = f * f; } else { throw new ArgumentException("Unhandled Unit type " + _unitsType); } return(f); }
public ConversionFacade(IReadableOutputCreator readOutputCreator, IUnitConverter unitConverter, IConversionTokenizer conversionTokenizer, IConversionModelBuilder conversionModelBuilder) { mReadableOutputCreator = readOutputCreator; mUnitConverter = unitConverter; mConversionTokenizer = conversionTokenizer; mConversionModelBuilder = conversionModelBuilder; }
public ConverterFlow(IUnitConverter unitConverter, ITeensConverter teensConverter, ITensConverter tensConverter, IOneHundredConverter oneHundredConverter) { _unitConverter = unitConverter; _teensConverter = teensConverter; _tensConverter = tensConverter; _oneHundredConverter = oneHundredConverter; }
public ScientificCalculator( IInputBuffer buffer, IOperatorLookup lookup, IUnitConverter unitConverter, IOperatorConverter operatorConverter, IExpressionBuilder builder, IExpressionParser parser, IEvaluate evaluator, IMemoryStorage memory ) : base( buffer, lookup, unitConverter, operatorConverter, builder, parser, evaluator, memory ) { }
public ProductPricingService(IUnitConverter unitConverter, IFxRateRepository fxRateRepository, IProductRepository productRepository) { _unitConverter = unitConverter; _fxRateRepository = fxRateRepository; _productRepository = productRepository; }
public void ConvertWith(IUnitConverter converter, string values) { var converted = _formatter.ToCollection(values) .Select(ParseToDouble) .Select(converter.Convert) .Select(ConvertToString); Result = _formatter.ToText(converted); }
public void GetInvalidConverter() { UnitConverter converter = new UnitConverter(); converter.Register <MassConverter>(); IUnitConverter unitConverter = converter.Get <ForceConverter>(); Assert.IsNull(unitConverter); }
public GenericConverterTests() { _tempConverter = new UnitConverter <Temperature, float> { BaseUnit = Temperature.Celsius }; _tempConverter.RegisterConversion(Temperature.Farenheit, v => (v - 32) * 5 / 9, v => (v * 9 / 5) + 32); _tempConverter.RegisterConversion(Temperature.Kelvin, v => v - 273.15f, v => (v + 273.15f)); // _converter = new Converter(); }
private void Initialize(String astringLabel, Dimension adimension, UnitSystem aunitsystem, IUnitConverter aiunitconverter, int aintEnumValue, String bentleyName) { m_stringName = astringLabel; m_iunitconverter = aiunitconverter; m_dimension = adimension; m_intEnumValue = aintEnumValue; m_dimension.Register(this); m_unitsystem = aunitsystem; m_bentleyName = bentleyName; }
public TestConverterPanel( IInputBuffer buffer, IKeyChecker checker, IFormatter formatter, IUnitConverter converter, IConverterDisplay display, string[] units ) : base(buffer, checker, formatter, converter, display, units) { }
static MainViewModel CreateMainViewModelWithDependencies() { var converters = new IUnitConverter[] { new YardsToMetersConverter(ConverterNames.YardsToMeters), new InchesToCentimetersConverter(ConverterNames.InchesToCentimeters), new MilesToKilometersConverter(ConverterNames.MilesToKilometers) }; var formatter = new TextFormatter(); return(new MainViewModel(formatter, converters)); }
public SettingsViewModel(IEventAggregator eventAggregator, ILayerReaderService <IntervalReaderSettings> intervalReaderService, ILayerReaderService <FileReaderSettings> fileReaderService, IUnitConverter converterService) { _intervalReaderService = intervalReaderService; _fileReaderService = fileReaderService; _converterService = converterService; _layerAddedEvent = eventAggregator.GetEvent <NewLayerAddedEvent>(); _requestBodyDrawEvent = eventAggregator.GetEvent <RequestBodyDrawEvent>(); RunDemo(); }
public Evaluator( IUnitConverter unitConverter, IOperatorConverter operatorConverter, IOperatorLookup operatorLookup ) { UnitConverter = unitConverter; OperatorConverter = operatorConverter; Lookup = operatorLookup; Initialize(); }
/// <summary> /// Convert the current quantity to a different unit. /// If the conversion is not possible an ArgumentException will be thrown. /// </summary> /// <remarks> /// IUnitConverter is a domain service and is used to keep the domain logic clean and simple. /// Adding all conversion details to the Quantity class directly would make the class very complex and make it much more difficult to maintain and test. /// By splitting the logic, both the Quantity and the converter are easy to test in isolation. /// Note that there are no implementations of the converter in the domain project. The implementations live in other parts such as the framework that interacts with the domain project. /// </remarks> /// <param name="newUnit">The unit to convert to.</param> /// <param name="converter">The converter used to perform the unit conversion.</param> /// <returns>The converted quantity.</returns> public Quantity ConvertTo(Unit newUnit, IUnitConverter converter) { if (null == newUnit) { throw new ArgumentNullException(nameof(newUnit)); } if (!converter.CanConvert(Unit, newUnit, out var conversionRatio)) { throw new ArgumentException($"Unit '{Unit.Name}' is not convertable to '{newUnit.Name}'.", nameof(newUnit)); } return(new Quantity(newUnit, Value * conversionRatio)); }
public ConverterPanel GetConverterPanel(IUnitConverter converter, IConverterDisplay display, string[] units) { LoadConverterPanelAsset(); return(new ConverterPanel( InputBuffer, KeyChecker, NumberFormatter, converter, display, units )); }
public DataProcessing(BlockingCollection <List <double> > dataQueue, BlockingCollection <List <double> > dataQueueToCalculation, DataCollection dataCollection) { //create variables _dataQueueToCalculation = dataQueueToCalculation; _dataQueue = dataQueue; //create relations _dataCollector = dataCollection; _calibrate = new Calibrate(); _unitConverter = new UnitConverter(); _digitalFilter = new DigitalFilter(); _zeroPointAdjustment = new ZeroPointAdjustment(); }
public ConverterManager(IUnitIndexConverter unitIndexConverter, IUnitConverter unitConverter, IJobIndexConverter jobIndexConverter, IJobConverter jobConverter, IEventPublisher publisher, IJobPositionConverter jobPositionConverter, IEmployeeConverter employeeConverter, IPeriodServiceWrapper periodService, IUnitIndexInPeriodServiceWrapper unitIndexService, IJobIndexInPeriodServiceWrapper jobIndexService) { this.unitIndexConverter = unitIndexConverter; this.unitConverter = unitConverter; this.jobIndexConverter = jobIndexConverter; this.jobConverter = jobConverter; this.publisher = publisher; this.jobPositionConverter = jobPositionConverter; this.employeeConverter = employeeConverter; this.periodService = periodService; this.unitIndexService = unitIndexService; this.jobIndexService = jobIndexService; }
public double ConvertESRIUnits(double dValue, esriUnits eInUnits, esriUnits eOutUnits) { try { if (this.mESRIConvertUnits == null) { this.mESRIConvertUnits = new UnitConverterClass(); } return(this.mESRIConvertUnits.ConvertUnits(dValue, eInUnits, eOutUnits)); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.UnitFun", "ConvertESRIUnits", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(-1.0); } }
public MainForm() { // Required for Windows Form Designer support. InitializeComponent(); uc = Thor.Units.InterfaceFactory.CreateUnitConverter(); uc.OnError += new UnitEventHandler(uc_OnError); uc.LoadUnitsFile(@".\units.xml"); /*DataString d1 = uc.CreateDataString("kg"); * DataString d2 = uc.CreateDataString("kg"); * * d1.SetValue("5 kg"); * d2.SetValue("500 g"); * * DataString d3 = d1 + d2; * * MessageBox.Show(d3.ToString( ));*/ }
public StandardCalculator( IInputBuffer buffer, IOperatorLookup lookup, IUnitConverter unitConverter, IOperatorConverter operatorConverter, IExpressionBuilder builder, IExpressionParser parser, IEvaluate evaluator, IMemoryStorage memory ) : base(buffer) { Lookup = lookup; UnitConverter = unitConverter; OperatorConverter = operatorConverter; Builder = builder; Parser = parser; Evaluator = evaluator; Memory = memory; }
public ConverterPanel( IInputBuffer buffer, IKeyChecker checker, IFormatter formatter, IUnitConverter converter, IConverterDisplay display, string[] units ) { InitializeComponent(); Buffer = buffer; Checker = checker; NumberFormatter = formatter; UnitConverter = converter; Helper = new UIHelper(); Units = units.ToArray(); SetupDisplay(display, units); SetupKeypad(); }
public void Setup() { buffer = new InputBuffer(); lookup = new OperatorLookup(); unitConverter = new AngleConverter(); operatorConverter = new OperatorConverter(lookup.Operators, lookup.Unary); parenthesizer = new Parenthesizer(lookup.Precedence); builder = new ExpressionBuilder(parenthesizer); parser = new ExpressionParser(operatorConverter); evaluator = new Evaluator(unitConverter, operatorConverter, lookup); memory = new MemoryStorage(); calculator = new ScientificCalculator( buffer, lookup, unitConverter, operatorConverter, builder, parser, evaluator, memory ); }
public MyTermVisitor(IUnitConverter unitConverter, IFxRateRepository fxRateRepository) { _unitConverter = unitConverter; _fxRateRepository = fxRateRepository; }
public Unit(String astringName, Dimension adimension, UnitSystem aunitsystem, IUnitConverter aiunitconverter, int aintEnumValue) : this(astringName, adimension, aunitsystem, aiunitconverter, aintEnumValue, String.Empty) { }
public Unit(String astringName, Dimension adimension, UnitSystem aunitsystem, IUnitConverter aiunitconverter, int aintEnumValue, String bentleyName) { Initialize(astringName, adimension, aunitsystem, aiunitconverter, aintEnumValue, bentleyName); }
public CurrencyBasedUnit(String astringName, Dimension adimension, UnitSystem aunitsystem, IUnitConverter aiunitconverter, int aintEnumValue, String bentleyName) : base(astringName, adimension, aunitsystem, aiunitconverter, aintEnumValue, bentleyName) { }
/// <summary> /// Calculates the volume using the provided input and strategy /// </summary> public async Task CalculateAsync(IReader baseReader, IReader topReader, NonNegativeDecimal gridWidth, NonNegativeDecimal gridHeight, NonNegativeDecimal fluidContact, IUnitConverter unitConverter, ILogger logger) { if (baseReader == null) { throw new ArgumentNullException(nameof(baseReader)); } if (topReader == null) { throw new ArgumentNullException(nameof(topReader)); } if (unitConverter == null) { throw new ArgumentNullException(nameof(unitConverter)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } try { var baseHorizon = await baseReader.ReadAsync(); logger.Info($"Found {baseHorizon.Width * baseHorizon.Height} data points for base horizon"); var topHorizon = await topReader.ReadAsync(); logger.Info($"Found {topHorizon.Width * topHorizon.Height} data points for top horizon"); if (baseHorizon.Height != topHorizon.Height || baseHorizon.Width != topHorizon.Width) { logger.Error("Invalid input: grids must have the same dimensions!"); return; } logger.Info("Calculating volume..."); var volume = _calculationStrategy.GetVolume(baseHorizon, topHorizon, gridWidth, gridHeight, fluidContact); logger.Info("Success!"); logger.Info(""); logger.Info($"- {unitConverter.ToBarrels(volume):N0} barrels of oil"); logger.Info($"- {unitConverter.ToCubicFeet(volume):N0} cubic feet"); logger.Info($"- {unitConverter.ToCubicMeter(volume):N0} cubic meter"); logger.Info("Volume between top horizon and base horizon/fluid contact is approximately:"); } catch (ReaderException e) { logger.Error($"Error while reading! {e.Message}"); } }
private Length(double val, IUnitConverter converter) { Val = val; Unit = converter.ConvertType; m_footValue = converter.ConvertToFoot(val); }
public InternalStockBooker(IUnitConverter unitConverter) : base(unitConverter) { }
public MealIngredient ConvertQuantity(Unit newUnit, IUnitConverter converter) => new MealIngredient(Ingredient, Quantity.ConvertTo(newUnit, converter), Preparation);
public TemperatureController(IUnitConverter <Temperature, float> converter) { _converter = converter; }
public StockBooker(IUnitConverter unitConverter) { _unitConverter = unitConverter; }
public HomeController(IRepository repository, IWeatherProvider weatherProvider, IUnitConverter unitConverter) { _repository = repository; _weatherProvider = weatherProvider; _unitConverter = unitConverter; }