public override EvaluationResult evaluate(Security security, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(security.GetType());

            // security
            Optional <string> securityPropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityPropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(securityPropertyName.get()).get((Bean)security);
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // security info
            Optional <string> securityInfoPropertyName = security.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityInfoPropertyName.Present)
            {
                object propertyValue = security.Info.property(securityInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // security price info
            Optional <string> securityPriceInfoPropertyName = security.Info.PriceInfo.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityPriceInfoPropertyName.Present)
            {
                object propertyValue = security.Info.PriceInfo.property(securityPriceInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // not found
            return(invalidTokenFailure(security, firstToken));
        }
Beispiel #2
0
        public override EvaluationResult evaluate(Trade trade, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(trade.GetType());

            // trade
            Optional <string> tradePropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (tradePropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(tradePropertyName.get()).get((Bean)trade);
                if (propertyValue == null)
                {
                    return(EvaluationResult.failure("Property '{}' not set", firstToken));
                }
                return(EvaluationResult.success(propertyValue, remainingTokens));
            }

            // trade info
            Optional <string> tradeInfoPropertyName = trade.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (tradeInfoPropertyName.Present)
            {
                object propertyValue = trade.Info.property(tradeInfoPropertyName.get()).get();
                if (propertyValue == null)
                {
                    return(EvaluationResult.failure("Property '{}' not set", firstToken));
                }
                return(EvaluationResult.success(propertyValue, remainingTokens));
            }
            return(invalidTokenFailure(trade, firstToken));
        }
        public override EvaluationResult evaluate(Position position, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(position.GetType());

            // position
            Optional <string> positionPropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (positionPropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(positionPropertyName.get()).get((Bean)position);
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // position info
            Optional <string> positionInfoPropertyName = position.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (positionInfoPropertyName.Present)
            {
                object propertyValue = position.Info.property(positionInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // not found
            return(invalidTokenFailure(position, firstToken));
        }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public org.joda.beans.MetaProperty<?> findMetaProperty(Class beanType, org.joda.beans.MetaBean metaBean, String propertyName)
        public override MetaProperty <object> findMetaProperty(Type beanType, MetaBean metaBean, string propertyName)
        {
            try
            {
                return(metaBean.metaProperty(propertyName));
            }
            catch (NoSuchElementException ex)
            {
                if (HOLIDAYS.name().Equals(propertyName))
                {
                    return(HOLIDAYS);
                }
                if (WEEKEND_DAYS.name().Equals(propertyName))
                {
                    return(WEEKEND_DAYS);
                }
                throw ex;
            }
        }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public org.joda.beans.MetaProperty<?> findMetaProperty(Class beanType, org.joda.beans.MetaBean metaBean, String propertyName)
        public override MetaProperty <object> findMetaProperty(Type beanType, MetaBean metaBean, string propertyName)
        {
            try
            {
                return(metaBean.metaProperty(propertyName));
            }
            catch (NoSuchElementException ex)
            {
                if (BASE_CURRENCY_AMOUNT.name().Equals(propertyName))
                {
                    return(BASE_CURRENCY_AMOUNT);
                }
                if (COUNTER_CURRENCY_AMOUNT.name().Equals(propertyName))
                {
                    return(COUNTER_CURRENCY_AMOUNT);
                }
                if (PAYMENT_DATE.name().Equals(propertyName))
                {
                    return(PAYMENT_DATE);
                }
                throw ex;
            }
        }