コード例 #1
0
        public CallbackDelegate GetMember(string name)
        {
            // get the event name
            var eventName = $"__cfx_export_base-rush_{name}";

            // get the member
            var exportDelegate = new DelegateFn();

            BaseScript.TriggerEvent(eventName, new Action <CallbackDelegate>(a => exportDelegate.Delegate = a));

            return(exportDelegate.Delegate);
        }
        public virtual void oneDerivedFunction()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5));
            DelegateFn           delegateFn           = new DelegateFn(delegateResults);
            DerivedFn            derivedFn            = new DerivedFn();
            CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn);
            CalculationFunctions derivedFunctions     = calculationFunctions.composedWith(derivedFn);
            TestTarget           target = new TestTarget(42);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            CalculationFunction <object> function = derivedFunctions.getFunction(target);

            ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE);

            assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures);
        }
コード例 #3
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            // get the event name
            var eventName = $"__cfx_export_{m_resourceName}_{binder.Name}";

            // get the member
            var exportDelegate = new DelegateFn();

            BaseScript.TriggerEvent(eventName, new Action <dynamic>(a => exportDelegate.Delegate = a));

            if (exportDelegate.Delegate == null)
            {
                result = null;
                return(false);
            }

            // try invoking it
            result = exportDelegate.Delegate(args);

            return(true);
        }
        /// <summary>
        /// Test that multiple derived functions for the same target type are correctly combined when one derived function
        /// depends on another.
        /// </summary>
        public virtual void multipleDerivedFunctionsForSameTargetTypeWithDependencyBetweenDerivedFunctions()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5));
            DelegateFn delegateFn = new DelegateFn(delegateResults);
            DerivedFn  derivedFn1 = new DerivedFn();
            // This depends on the measure calculated by derivedFn1
            DerivedFn derivedFn2 = new DerivedFn(PRESENT_VALUE_MULTI_CCY, ImmutableSet.of(BUCKETED_PV01));

            CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn);
            // The derived functions must be specified in the correct order.
            // The function higher up the dependency chain must come second
            CalculationFunctions derivedFunctions = calculationFunctions.composedWith(derivedFn1, derivedFn2);
            TestTarget           target           = new TestTarget(42);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            CalculationFunction <object> function = derivedFunctions.getFunction(target);

            ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE, PRESENT_VALUE_MULTI_CCY);

            assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures);
        }