Esempio n. 1
0
        /******************************************************************************/

        private currencyPerKWhType generateCurrencyPerKWh(currencyItemDescriptionType description)
        {
            currencyPerKWhType currency = new currencyPerKWhType();

            currency.itemDescription = description;
            currency.itemUnits       = ISO3AlphaCurrencyCodeContentType.USD;
            currency.siScaleCode     = SiScaleCodeType.none;

            return(currency);
        }
Esempio n. 2
0
        /// <summary>
        /// validates currency type units.  assumes three valid signals: price and priceRelative with units of curencyType, and
        /// priceMultiplier with no units
        /// </summary>
        /// <param name="signalType"></param>
        /// <param name="units"></param>
        /// <param name="currencyDescriptonType"></param>
        public static void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units, currencyItemDescriptionType currencyDescriptonType)
        {
            if (signalType == SignalTypeEnumeratedType.price || signalType == SignalTypeEnumeratedType.priceRelative)
            {
                // the class could be currencyType, or a sub class currencyPerKWh, currencyPerKW type
                if (units.GetType().BaseType != typeof(currencyType) && units.GetType() != typeof(currencyType))
                {
                    throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS);
                }

                currencyType c = (currencyType)units;

                if (c.itemDescription != currencyDescriptonType)
                {
                    throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS);
                }

                return;
            }

            if (signalType == SignalTypeEnumeratedType.priceMultiplier)
            {
                if (units != null)
                {
                    throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS);
                }

                return;
            }

            throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE);
        }