Exemple #1
0
        /// <summary>
        /// Create a new content item from the database row
        /// </summary>
        /// <param name="knownSoFar">Used to find the baseUOM, not to check for consistency (which is done outside this routine)</param>
        public static KnownUOM NewContentItem(string packageName, TblUOM_Row t1, Dictionary <string, KnownUOM> knownSoFar)
        {
            bool     isBase  = t1.IsBase;
            KnownUOM baseUOM = null;

            if (!isBase)
            {
                foreach (var item in knownSoFar)
                {
                    if (Dimensions.AreEqual(item.Value.Dimensions, t1.Dimensions))
                    {
                        baseUOM = item.Value;
                        break;
                    }
                }
                if (baseUOM == null)
                {
                    int iDbg = 0;
                    throw new UnspecifiedException();
                }
            }

            KnownUOM knownUOM = new KnownUOM(packageName, t1.Dimensions,
                                             t1.Name, t1.Description, t1.Symbol,
                                             isBase, baseUOM,
                                             t1.Factor_A, t1.Factor_B, t1.Factor_C, t1.Factor_D);

            return(knownUOM);
        }
Exemple #2
0
        }                                                                    // If true, calculation will only be called if all the args are known, and we don't expect the calculation to change any of the args

        // ---------------------------------------

        public override Result <Dimensions> CalcDimensions(IList <Dimensions> argDimensions, IList <double?> argConstants)
        {
            if (argDimensions.Count != 2)
            {
                return(Result <Dimensions> .Bad(Name + " must have 2 arguments"));
            }

            if (argDimensions[0] == null && argDimensions[1] == null)
            {
                return(Result <Dimensions> .Good(null));
            }

            if (!Dimensions.AreEqual(argDimensions[0], argDimensions[1]))
            {
                return(Result <Dimensions> .Bad("Inconsistent Dimensions"));
            }

            return(Result <Dimensions> .Good(argDimensions[0]));
        }