コード例 #1
0
ファイル: ProController.cs プロジェクト: folterj/ProMISE2
 public void setXScale(QuantityType units)
 {
     viewParams.viewUnits = units;
     updateOutReq         = true;
     updateTimeOutReq     = true;
     updateViewParams();
 }
コード例 #2
0
        /// <summary>
        ///     Constructs an instance.
        /// </summary>
        /// <param name="name">Name of the quantity.</param>
        /// <param name="unitInfos">The information about the units for this quantity.</param>
        /// <param name="baseUnit">The base unit enum value.</param>
        /// <param name="zero">The zero quantity.</param>
        /// <param name="baseDimensions">The base dimensions of the quantity.</param>
        /// <param name="quantityType">The the quantity type. Defaults to Undefined.</param>
        /// <exception cref="ArgumentException">Quantity type can not be undefined.</exception>
        /// <exception cref="ArgumentNullException">If units -or- baseUnit -or- zero -or- baseDimensions is null.</exception>
        public QuantityInfo([NotNull] string name, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions,
                            QuantityType quantityType = QuantityType.Undefined)
        {
            if (baseUnit == null)
            {
                throw new ArgumentNullException(nameof(baseUnit));
            }

            BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions));
            Zero           = zero ?? throw new ArgumentNullException(nameof(zero));

            Name           = name;
            UnitType       = UnitEnumTypes.First(t => t.Name == $"{name}Unit");
            UnitInfos      = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos));
            BaseUnitInfo   = UnitInfos.First(unitInfo => unitInfo.Value.Equals(baseUnit));
            Zero           = zero ?? throw new ArgumentNullException(nameof(zero));
            ValueType      = zero.GetType();
            BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions));

            // Obsolete members
            UnitNames    = UnitInfos.Select(unitInfo => unitInfo.Name).ToArray();
            Units        = UnitInfos.Select(unitInfo => unitInfo.Value).ToArray();
            BaseUnit     = BaseUnitInfo.Value;
            QuantityType = quantityType;
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Type,Description,IsActive,IsDeleted,DeletedOn,Id,CreatedOn,ModifiedOn")] QuantityType quantityType)
        {
            if (id != quantityType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(quantityType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuantityTypeExists(quantityType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(quantityType));
        }
コード例 #4
0
ファイル: ViewParams.cs プロジェクト: folterj/ProMISE2
        public void init(InParams inParams)
        {
            if (viewType == ViewType.Setup)
            {
                phaseDisplay = PhaseDisplayType.All;
            }
            else if (viewType == ViewType.Time)
            {
                phaseDisplay = PhaseDisplayType.UpperLower;
            }
            else if (inParams.runMode == RunModeType.LowerPhase)
            {
                phaseDisplay = PhaseDisplayType.All;
            }
            else if (inParams.runMode == RunModeType.UpperPhase)
            {
                phaseDisplay = PhaseDisplayType.All;
            }
            else
            {
                phaseDisplay = PhaseDisplayType.UpperLowerTime;
            }

            syncScales    = (inParams.runMode == RunModeType.CoCurrent);
            peaksDisplay  = PeaksDisplayType.PeaksSum;
            yScale        = YScaleType.Automatic;
            exponentType  = ExponentType.Exponents;
            viewUnits     = inParams.viewUnits;
            showProbUnits = (inParams.model == ModelType.Probabilistic && viewType != ViewType.Setup);
            autoZoom      = true;
            update(inParams);
        }
コード例 #5
0
        public Quantity quantity;         /*!< the quantity */

        /*! @brief		The default constructor.
         *      @param node	the XmlNode to create this object from.
         */
        public QuantitySample(XmlNode node) : base(node)
        {
            this.quantity = new Quantity(node["quantity"]);
            string aggregationStyle = node.SelectSingleNode("quantityType/aggregationStyle").InnerText;

            this.quantityType = (aggregationStyle == "cumulative") ? QuantityType.cumulative : QuantityType.discrete;
        }
コード例 #6
0
        private static List <QuantityType> GetQuantityTypes(XmlNodeList qtNodes)
        {
            var quantityTypes = new List <QuantityType>();

            foreach (XmlNode qType in qtNodes)
            {
                var notation = qType.InnerText;

                QuantityType qt;

                if (!_quantityTypes.ContainsKey(notation))
                {
                    qt = new QuantityType(notation);
                    _quantityTypes.Add(notation, qt);
                }
                else
                {
                    qt = _quantityTypes[notation];
                }

                quantityTypes.Add(qt);
            }

            return(quantityTypes);
        }
コード例 #7
0
        /// <summary>
        ///     Constructs an instance.
        /// </summary>
        /// <param name="quantityType">The quantity enum value.</param>
        /// <param name="unitInfos">The information about the units for this quantity.</param>
        /// <param name="baseUnit">The base unit enum value.</param>
        /// <param name="zero">The zero quantity.</param>
        /// <param name="baseDimensions">The base dimensions of the quantity.</param>
        /// <exception cref="ArgumentException">Quantity type can not be undefined.</exception>
        /// <exception cref="ArgumentNullException">If units -or- baseUnit -or- zero -or- baseDimensions is null.</exception>
        public QuantityInfo(QuantityType quantityType, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions)
        {
            if (quantityType == QuantityType.Undefined)
            {
                throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType));
            }
            if (baseUnit == null)
            {
                throw new ArgumentNullException(nameof(baseUnit));
            }

            BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions));
            Zero           = zero ?? throw new ArgumentNullException(nameof(zero));


            Name           = quantityType.ToString();
            QuantityType   = quantityType;
            UnitType       = UnitEnumTypes.First(t => t.Name == $"{quantityType}Unit");
            UnitInfos      = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos));
            BaseUnitInfo   = UnitInfos.First(unitInfo => unitInfo.Value.Equals(baseUnit));
            Zero           = zero ?? throw new ArgumentNullException(nameof(zero));
            ValueType      = zero.GetType();
            BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions));

            // Obsolete members
#pragma warning disable 618
            UnitNames = UnitInfos.Select(unitInfo => unitInfo.Name).ToArray();
            Units     = UnitInfos.Select(unitInfo => unitInfo.Value).ToArray();
            BaseUnit  = BaseUnitInfo.Value;
#pragma warning restore 618
        }
コード例 #8
0
        public static IReadOnlyList <object> GetUnits(QuantityType quantity)
        {
            // Ex: Find unit enum type UnitsNet.Units.LengthUnit from quantity enum name QuantityType.Length
            Type unitEnumType = UnitEnumTypes.First(t => t.FullName == $"UnitsNet.Units.{quantity}Unit");

            return(Enum.GetValues(unitEnumType).Cast <object>().Skip(1).ToArray());
        }
コード例 #9
0
        private KeyPathMap calculationKeyFor(IEnumerable <string> quantityPath, QuantityType quantityType, bool removeFirstEntry)
        {
            var path         = new List <string>(quantityPath);
            var moleculeName = string.Empty;

            if (removeFirstEntry && path.Count > 1)
            {
                path.RemoveAt(0);
            }

            //path represents a molecule amount. Name of molecule is last entry
            if (path.Count >= 1 && quantityTypeIsMoleculeAmount(quantityType))
            {
                moleculeName = path[path.Count - 1];
                path.RemoveAt(path.Count - 1);
            }

            //if the path contains at least 2 elements and represents a molecule remove
            //the one before last entry corresponding to the molecule name
            else if (path.Count >= 2 && quantityTypeIsMoleculeObserver(quantityType))
            {
                moleculeName = path[path.Count - 2];
                path.RemoveAt(path.Count - 2);
            }

            return(new KeyPathMap(path.ToPathString(), moleculeName));
        }
コード例 #10
0
        private static TAttribute?GetAttribute <TAttribute>(ITypeDescriptorContext?context) where TAttribute : UnitAttributeBase
        {
            if (context is null || context.PropertyDescriptor is null)
            {
                return(null);
            }

            TAttribute?attribute = (TAttribute)context.PropertyDescriptor.Attributes[typeof(TAttribute)];

            if (attribute != null)
            {
                QuantityType expected = default(TQuantity).Type;
                QuantityType actual   = QuantityType.Undefined;

                if (attribute.UnitType != null)
                {
                    actual = Quantity.From(1, attribute.UnitType).Type;
                }
                if (actual != QuantityType.Undefined && expected != actual)
                {
                    throw new ArgumentException($"The specified UnitType:'{attribute.UnitType}' dose not match QuantityType:'{expected}'");
                }
            }

            return(attribute);
        }
コード例 #11
0
        private IMoleculeBuilder createFor(QuantityType moleculeType, IFormulaCache formulaCache)
        {
            switch (moleculeType)
            {
            case QuantityType.Drug:
                return(_moleculeMapper.MapFrom(_flatMoleculeRepository.FindBy(QuantityType.Drug), formulaCache)
                       .WithIcon(ApplicationIcons.Drug.IconName));

            case QuantityType.Enzyme:
            case QuantityType.OtherProtein:
                return(defaultProteinMoleculeFrom(moleculeType, formulaCache));

            case QuantityType.Transporter:
                return(defaultTransporterMoleculeFrom(formulaCache));

            case QuantityType.Metabolite:
            case QuantityType.Complex:
                return(defaultReactionProduct(moleculeType, formulaCache));

            case QuantityType.Undefined:
                return(defaultFloatingNonXenobioticMolecule(moleculeType, formulaCache));

            default:
                throw new ArgumentOutOfRangeException(nameof(moleculeType));
            }
        }
コード例 #12
0
        public QuantityType GetQuantityType(PotentialTwinCombo combo)
        {
            QuantityType qType = QuantityType.None;

            switch (combo)
            {
            case PotentialTwinCombo.NoNulls:
                qType = QuantityType.Multiple;
                break;

            case PotentialTwinCombo.RowsAndColumns:
                qType = QuantityType.Multiple;
                break;

            case PotentialTwinCombo.RowsAndSubgrids:
                qType = QuantityType.Multiple;
                break;

            case PotentialTwinCombo.ColumnsAndSubgrids:
                qType = QuantityType.Multiple;
                break;

            case PotentialTwinCombo.OnlyRows:
                if (potentialRows.Count == 1)
                {
                    qType = QuantityType.Singular;
                }
                else
                {
                    qType = QuantityType.Multiple;
                }
                break;

            case PotentialTwinCombo.OnlyColumns:
                if (potentialColumns.Count == 1)
                {
                    qType = QuantityType.Singular;
                }
                else
                {
                    qType = QuantityType.Multiple;
                }
                break;

            case PotentialTwinCombo.OnlySubgrids:
                if (potentialSubgrids.Count == 1)
                {
                    qType = QuantityType.Singular;
                }
                else
                {
                    qType = QuantityType.Multiple;
                }
                break;

            case PotentialTwinCombo.AllNulls:
                break;
            }
            return(qType);
        }
コード例 #13
0
        public QuantityInfo(QuantityType quantityType, [NotNull] Enum[] units, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions)
        {
            if (quantityType == QuantityType.Undefined)
            {
                throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType));
            }
            if (units == null)
            {
                throw new ArgumentNullException(nameof(units));
            }
            if (baseUnit == null)
            {
                throw new ArgumentNullException(nameof(baseUnit));
            }
            if (zero == null)
            {
                throw new ArgumentNullException(nameof(zero));
            }
            if (baseDimensions == null)
            {
                throw new ArgumentNullException(nameof(baseDimensions));
            }

            Name           = quantityType.ToString();
            QuantityType   = quantityType;
            UnitType       = UnitEnumTypes.First(t => t.Name == $"{quantityType}Unit");
            UnitInfos      = units.Select(unit => new UnitInfo(unit)).ToArray();
            UnitNames      = UnitInfos.Select(unitInfo => unitInfo.Name).ToArray();
            Units          = units;
            BaseUnitInfo   = new UnitInfo(baseUnit);
            BaseUnit       = BaseUnitInfo.Value;
            Zero           = zero;
            ValueType      = zero.GetType();
            BaseDimensions = baseDimensions;
        }
コード例 #14
0
ファイル: PQDIFReader.cs プロジェクト: daozh/openXDA
        /// <summary>
        /// Parses the file into a meter data set per meter contained in the file.
        /// </summary>
        /// <param name="filePath">The path to the file to be parsed.</param>
        /// <returns>List of meter data sets, one per meter.</returns>
        public void Parse(string filePath)
        {
            DataSourceRecord              dataSource = null;
            ObservationRecord             observation;
            IEnumerable <ChannelInstance> channelInstances;

            Meter      meter = null;
            Channel    channel;
            DataSeries dataSeries;

            DateTime[] timeData;

            while (m_parser.HasNextObservationRecord())
            {
                observation = m_parser.NextObservationRecord();

                if ((object)observation.DataSource == null)
                {
                    continue;
                }

                if ((object)dataSource == null)
                {
                    dataSource           = observation.DataSource;
                    meter                = ParseDataSource(dataSource);
                    m_meterDataSet.Meter = meter;
                }

                if (!AreEquivalent(dataSource, observation.DataSource))
                {
                    throw new InvalidDataException($"PQDIF file \"{filePath}\" defines too many data sources.");
                }

                channelInstances = observation.ChannelInstances
                                   .Where(channelInstance => QuantityType.IsQuantityTypeID(channelInstance.Definition.QuantityTypeID))
                                   .Where(channelInstance => channelInstance.SeriesInstances.Any())
                                   .Where(channelInstance => channelInstance.SeriesInstances[0].Definition.ValueTypeID == SeriesValueType.Time);

                foreach (ChannelInstance channelInstance in channelInstances)
                {
                    timeData = ParseTimeData(channelInstance);

                    foreach (SeriesInstance seriesInstance in channelInstance.SeriesInstances.Skip(1))
                    {
                        channel = ParseSeries(seriesInstance);

                        dataSeries            = new DataSeries();
                        dataSeries.DataPoints = timeData.Zip(ParseValueData(seriesInstance), (time, d) => new DataPoint()
                        {
                            Time = time, Value = d
                        }).ToList();
                        dataSeries.SeriesInfo = channel.Series[0];

                        meter.Channels.Add(channel);
                        m_meterDataSet.DataSeries.Add(dataSeries);
                    }
                }
            }
        }
コード例 #15
0
        public ActionResult DeleteConfirmed(byte id)
        {
            QuantityType quantitytype = db.QuantityTypes.Find(id);

            db.QuantityTypes.Remove(quantitytype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #16
0
        public void Test_GetQuaantity()
        {
            QuantityTypeService service = QuantityTypeService.getService();
            QuantityType        ltype   = service.getType("Length") as QuantityType;
            IQuantity           l       = ltype.getQuantity();

            Assert.IsType <Length>(l);
        }
コード例 #17
0
        public ShoppingListItem Create(string name)
        {
            // ugly
            var quantityType         = new QuantityType(0, "", 1, "€", "x", 1);
            var quantityTypeInPacket = new QuantityTypeInPacket(0, "", "");

            return(new ShoppingListItem(new ItemId(Guid.NewGuid()), name, true, 1f, quantityType, 1, quantityTypeInPacket, "", "", false, 1));
        }
コード例 #18
0
        /// <summary>
        /// Add an entry to the quantity map.
        /// </summary>
        /// <param name="entry">The entry to add.</param>
        public QuantityEntry AddEntry(string name, string revitName, QuantityType quantityType, PropertyCalculator calculator)
        {
            QuantityEntry ifcQE = new QuantityEntry(revitName, name);

            ifcQE.QuantityType       = quantityType;
            ifcQE.PropertyCalculator = calculator;
            AddEntry(ifcQE);
            return(ifcQE);
        }
コード例 #19
0
        protected virtual void OnQuantityTypeChanged(QuantityType quantityType)
        {
            EventHandler <QuantityType> handler = QuantityTypeChanged;

            if (handler != null)
            {
                handler(this, quantityType);
            }
        }
コード例 #20
0
        /// <summary>
        ///     Gets the default unit information for the given quantity type, associated with the current unit system.
        ///     For example: the default unit of length in SI is the 'meter' abbreviated with the letter 'm'.
        ///     It is possible to customize the associations by creating derived UnitSystems (immutable) using the method
        ///     <see cref="WithDefaultUnit" />.
        /// </summary>
        /// <param name="quantityType">The quantity type of interest.</param>
        /// <returns>
        ///     The default UnitInfo for the given quantity type, if such an association exists,
        ///     and <see langword="null" /> otherwise.
        /// </returns>
        /// <exception cref="ArgumentException">
        ///     Quantity type can not be undefined.
        /// </exception>
        public UnitInfo?GetDefaultUnitInfo(QuantityType quantityType)
        {
            if (quantityType == QuantityType.Undefined)
            {
                throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType));
            }

            return(GetSystemInfo(_systemUnits.Value, quantityType)?.BaseUnit); // valid QuantityTypes start from 1 (0 == Undefined)
        }
コード例 #21
0
        private IMoleculeBuilder defaultProteinMoleculeFrom(QuantityType moleculeType, IFormulaCache formulaCache)
        {
            var molecule = _moleculeMapper.MapFrom(_flatMoleculeRepository.FindBy(QuantityType.Protein), formulaCache);

            molecule.QuantityType = moleculeType;
            molecule.IsXenobiotic = false;
            addDrugParametersTo(molecule, formulaCache);
            return(molecule);
        }
コード例 #22
0
        /// <summary>
        ///     Gets the list of commonly used (derived or named) units for the given quantity type, associated with the current
        ///     unit system.
        ///     For example: the default unit of length in SI is the 'meter' abbreviated with the letter 'm'.
        ///     It is possible to customize the associations by creating derived UnitSystems (immutable) using the method
        ///     <see cref="WithDefaultUnit" />.
        /// </summary>
        /// <param name="quantityType">The quantity type of interest.</param>
        /// <returns>
        ///     The array of UnitInfo for the given quantity type, if such an association exists,
        ///     and <see langword="null" /> otherwise.
        /// </returns>
        /// <exception cref="ArgumentException">
        ///     Quantity type can not be undefined.
        /// </exception>
        public UnitInfo[]? GetCommonUnitsInfo(QuantityType quantityType)
        {
            if (quantityType == QuantityType.Undefined)
            {
                throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType));
            }

            return(GetSystemInfo(_systemUnits.Value, quantityType)?.DerivedUnits); // valid QuantityTypes start from 1 (0 == Undefined)
        }
コード例 #23
0
        /// <summary>
        /// Add an entry to the quantity map.
        /// </summary>
        /// <param name="entry">The entry to add.</param>
        public QuantityEntry AddEntry(string name, BuiltInParameter parameterName, QuantityType quantityType, PropertyCalculator calculator)
        {
            QuantityEntry ifcQE = new QuantityEntry(name, parameterName);

            ifcQE.QuantityType       = quantityType;
            ifcQE.PropertyCalculator = calculator;
            AddEntry(ifcQE);
            return(ifcQE);
        }
コード例 #24
0
 public ActionResult Edit(QuantityType quantitytype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quantitytype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(quantitytype));
 }
コード例 #25
0
        public IMoleculeBuilder Create(QuantityType moleculeType, IFormulaCache formulaCache)
        {
            var moleculeBuilder = createFor(moleculeType, formulaCache);

            moleculeBuilder.Dimension = _dimensionRepository.Amount;
            moleculeBuilder.DefaultStartFormula.Dimension = _dimensionRepository.Amount;
            addFormulaToCacheIfNecessary(moleculeBuilder.DefaultStartFormula, formulaCache);
            addConcentrationParmeterTo(moleculeBuilder, formulaCache);
            return(moleculeBuilder);
        }
コード例 #26
0
        protected UnitSystemBase(TUnitEnum defualtUnit, double defaultValue, QuantityType quantityType, UnitConverterBase <TUnitEnum> converter) : base(defaultValue, quantityType)
        {
            Converter = converter;
            var supportedUnits = Enum.GetValues(typeof(TUnitEnum)).Cast <TUnitEnum>();

            DefaultUnit      = _selectedUnit = defualtUnit;
            SupportedUnits   = new List <TUnitEnum>(supportedUnits);
            _unSupportedUnit = SupportedUnits.ElementAt(0);
            ErrorDictionary[SelectedUnitConst] = SelectedUnitValue;
        }
    public void QuantityType_WithNull_ReturnsNull() {
      // Arrange
      QuantityType quantity = null;

      // Act
      XElement element = quantity.Serialize("Quantity");

      // Assert
      Assert.IsNull(element, "element should be null when quantitytype is null");
    }
コード例 #28
0
 public ChangeMoleculeTypeCommand(IMoleculeBuilder moleculeBuilder, QuantityType newType, QuantityType oldType, IBuildingBlock buildingBlock) : base(buildingBlock)
 {
     _moleculeBuilder   = moleculeBuilder;
     _moleculeBuilderId = _moleculeBuilder.Id;
     _newType           = newType;
     _oldType           = oldType;
     ObjectType         = ObjectTypes.Molecule;
     CommandType        = AppConstants.Commands.EditCommand;
     Description        = AppConstants.Commands.EditDescription(ObjectType, AppConstants.Captions.MoleculeType, Enum.GetName(typeof(QuantityType), oldType), Enum.GetName(typeof(QuantityType), newType), moleculeBuilder.Name);
 }
コード例 #29
0
ファイル: UnitSystemTests.cs プロジェクト: lipchev/UnitsNet
        public void GetDefaultUnitInfo_GivenUndefinedQuantityType_ReturnsNull(QuantityType baseType)
        {
            UnitSystem unitSystem = UnitSystem.SI;

            // since Length, Mass etc are part of the BaseUnits definition, we need to derive from UnitSystem (instead of BaseUnitSystem)
            var unitSystemWithNoDefaultUnit = unitSystem.WithDefaultUnit(baseType, null); // force the dissociation

            Assert.IsType <UnitSystem>(unitSystemWithNoDefaultUnit);
            Assert.Null(unitSystemWithNoDefaultUnit.GetDefaultUnitInfo(baseType));
        }
コード例 #30
0
        //
        // GET: /Admin/Qty/Delete/5

        public ActionResult Delete(byte id = 0)
        {
            QuantityType quantitytype = db.QuantityTypes.Find(id);

            if (quantitytype == null)
            {
                return(HttpNotFound());
            }
            return(View(quantitytype));
        }
コード例 #31
0
ファイル: MarketQuotes.cs プロジェクト: smarkets/IronSmarkets
 private MarketQuotes(
     Uid uid,
     ContractQuotesMap contractQuotes,
     PriceType priceType,
     QuantityType quantityType)
 {
     _uid = uid;
     _contractQuotes = contractQuotes;
     _priceType = priceType;
     _quantityType = quantityType;
 }
コード例 #32
0
 private ContractQuotes(
     Uid uid,
     IEnumerable<Quote> bids,
     IEnumerable<Quote> offers,
     IEnumerable<Execution> executions,
     Execution? lastExecution,
     PriceType priceType,
     QuantityType quantityType)
 {
     _uid = uid;
     _bids = GetQuoteDict(bids, Price.BidOrder);
     _offers = GetQuoteDict(offers, Price.OfferOrder);
     _executions = new List<Execution>(executions);
     _lastExecution = lastExecution;
     _priceType = priceType;
     _quantityType = quantityType;
 }
コード例 #33
0
 public QuantityMeasurement(QuantityType type, string text)
 {
     this.Type = type;
     this.Text = text;
 }
コード例 #34
0
 internal static ContractQuotes Empty(Uid uid, PriceType priceType, QuantityType quantityType)
 {
     return new ContractQuotes(
         uid,
         Enumerable.Empty<Quote>(),
         Enumerable.Empty<Quote>(),
         Enumerable.Empty<Execution>(),
         null,
         priceType,
         quantityType);
 }
コード例 #35
0
 public static decimal GetQuantityOfType(this InventoryItem inv, QuantityType qType)
 {
     var qty = inv.Quantity.Find(q => q.Type == qType);
     return qty == null ? 0 : qty.Quantity;
 }
コード例 #36
0
 private static Func<Proto.Seto.Execution, Execution> ExecutionFromSeto(
     PriceType priceType,
     QuantityType quantityType)
 {
     return x => Execution.FromSeto(x, priceType, quantityType);
 }
コード例 #37
0
 internal static ContractQuotes FromSeto(
     Proto.Seto.ContractQuotes setoQuotes,
     PriceType priceType,
     QuantityType quantityType)
 {
     return new ContractQuotes(
         Uid.FromUuid128(setoQuotes.Contract),
         setoQuotes.Bids.Select(QuoteFromSeto(priceType, quantityType)),
         setoQuotes.Offers.Select(QuoteFromSeto(priceType, quantityType)),
         setoQuotes.Executions.Select(ExecutionFromSeto(priceType, quantityType)),
         Execution.MaybeFromSeto(setoQuotes.LastExecution, priceType, quantityType),
         priceType,
         quantityType);
 }
コード例 #38
0
        /// <summary>
        /// Konwertuje typ pojemnościowy produktu na wartość zapisaną do bazy danych.
        /// </summary>
        /// <param name="typeEnum"><see cref="QuantityType"/></param>
        /// <returns></returns>
        private Int32 GetQuantityTypeValue(QuantityType typeEnum)
        {
            Int32 value = 0;

            if (typeEnum == QuantityType.Grams)
                value = 0;
            else if (typeEnum == QuantityType.Milliliters)
                value = 1;
            else if (typeEnum == QuantityType.Piece)
                value = 2;
            else if (typeEnum == QuantityType.Package)
                value = 3;
            else
                throw new NotSupportedException(nameof(typeEnum));

            return value;
        }
コード例 #39
0
 private static Func<Proto.Seto.Quote, Quote> QuoteFromSeto(
     PriceType priceType,
     QuantityType quantityType)
 {
     return x => Quote.FromSeto(x, priceType, quantityType);
 }