コード例 #1
0
ファイル: Adapter.cs プロジェクト: shao130/OpenFMSL
        Variable GetConstant(XElement xElement, ConstantProperties prop)
        {
            if (xElement == null)
            {
                throw new ArgumentException("xElement was null");
            }
            var uom      = ParseUOM((string)xElement.Attribute("units"));
            var constant = new Variable(prop.ToString(), (double)xElement.Attribute("value"), uom);

            return(constant);
        }
コード例 #2
0
        /// <summary>
        /// Retrieve the constant for a given constant ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Variable GetConstant(ConstantProperties id)
        {
            var constant = Constants.FirstOrDefault(c => c.Name == id.ToString());

            if (constant != null)
            {
                return(constant);
            }
            else
            {
                throw new ArgumentException("Constant ID not found");
            }
        }