コード例 #1
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;
        }
コード例 #2
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
        }
 public static QuantityTypeReadModel ToReadModel(this QuantityType quantityType)
 {
     return(new QuantityTypeReadModel(
                (int)quantityType,
                quantityType.ToString(),
                quantityType.GetAttribute <DefaultQuantityAttribute>().DefaultQuantity,
                quantityType.GetAttribute <PriceLabelAttribute>().PriceLabel,
                quantityType.GetAttribute <QuantityLabelAttribute>().QuantityLabel,
                quantityType.GetAttribute <QuantityNormalizerAttribute>().Value));
 }
コード例 #4
0
        private IMoleculeBuilder defaultFloatingNonXenobioticMolecule(QuantityType moleculeType, IFormulaCache formulaCache)
        {
            var molecule = _objectBaseFactory.Create <IMoleculeBuilder>();

            molecule.QuantityType        = moleculeType;
            molecule.Name                = moleculeType.ToString();
            molecule.DefaultStartFormula = _objectBaseFactory.Create <ConstantFormula>().WithValue(0);
            molecule.IsFloating          = true;
            molecule.IsXenobiotic        = false;
            return(molecule);
        }
コード例 #5
0
        private IMoleculeBuilder defaultReactionProduct(QuantityType moleculeType, IFormulaCache formulaCache)
        {
            var metabolite = _objectBaseFactory.Create <IMoleculeBuilder>();

            addDrugParametersTo(metabolite, formulaCache);
            metabolite.QuantityType        = moleculeType;
            metabolite.Name                = moleculeType.ToString();
            metabolite.DefaultStartFormula = _objectBaseFactory.Create <ConstantFormula>().WithValue(0);
            metabolite.IsFloating          = false;
            metabolite.IsXenobiotic        = true;
            return(metabolite);
        }
コード例 #6
0
ファイル: QuantityType.cs プロジェクト: Majunga/Food
        public static string GetFriendlyString(this QuantityType quantityType)
        {
            var fieldInfo = quantityType.GetType().GetField(quantityType.ToString());

            var descriptionAttributes = fieldInfo.GetCustomAttributes(
                typeof(DisplayAttribute), false) as DisplayAttribute[];

            if ((descriptionAttributes ?? throw new InvalidOperationException()).Any() && descriptionAttributes[0].ResourceType != null)
            {
                return(lookupResource(descriptionAttributes[0].ResourceType, descriptionAttributes[0].Name));
            }

            return((descriptionAttributes.Length > 0) ? descriptionAttributes[0].Name : quantityType.ToString());
        }
コード例 #7
0
 public QuantityInfo(QuantityType quantityType, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions)
     : this(quantityType.ToString(), unitInfos, baseUnit, zero, baseDimensions, quantityType)
 {
 }
コード例 #8
0
        public ExpressionProfile Create(QuantityType moleculeType, string speciesName, string moleculeName)
        {
            var species = _speciesRepository.FindByName(speciesName);

            switch (moleculeType)
            {
            case QuantityType.Enzyme:
                return(Create <IndividualEnzyme>(species, moleculeName));

            case QuantityType.OtherProtein:
                return(Create <IndividualOtherProtein>(species, moleculeName));

            case QuantityType.Transporter:
                return(Create <IndividualTransporter>(species, moleculeName));

            default:
                throw new OSPSuiteException(PKSimConstants.Error.MoleculeTypeNotSupported(moleculeType.ToString()));
            }
        }