コード例 #1
0
        public LogicalValue Resolve(Value source, LocalCodeExecutionContext localCodeExecutionContext, ResolverOptions options, bool forInheritance)
        {
#if DEBUG
            //Log($"source = {source}");
#endif

            var sourceKind = source.KindOfValue;

            switch (sourceKind)
            {
            case KindOfValue.NullValue:
                return(ValueConvertor.ConvertNullValueToLogicalValue(source.AsNullValue, _context));

            case KindOfValue.LogicalValue:
                return(source.AsLogicalValue);

            case KindOfValue.NumberValue:
                return(ValueConvertor.ConvertNumberValueToLogicalValue(source.AsNumberValue, _context));

            case KindOfValue.StrongIdentifierValue:
            {
                ReasonOfFuzzyLogicResolving reasonOfFuzzyLogicResolving = null;

                if (forInheritance)
                {
                    reasonOfFuzzyLogicResolving = new ReasonOfFuzzyLogicResolving()
                    {
                        Kind = KindOfReasonOfFuzzyLogicResolving.Inheritance
                    };
                }

                return(ValueConvertor.ConvertNumberValueToLogicalValue(_context.DataResolversFactory.GetFuzzyLogicResolver().Resolve(source.AsStrongIdentifierValue, reasonOfFuzzyLogicResolving, localCodeExecutionContext, options), _context));
            }


            case KindOfValue.FuzzyLogicNonNumericSequenceValue:
            {
                ReasonOfFuzzyLogicResolving reasonOfFuzzyLogicResolving = null;

                if (forInheritance)
                {
                    reasonOfFuzzyLogicResolving = new ReasonOfFuzzyLogicResolving()
                    {
                        Kind = KindOfReasonOfFuzzyLogicResolving.Inheritance
                    };
                }

                return(ValueConvertor.ConvertNumberValueToLogicalValue(_context.DataResolversFactory.GetFuzzyLogicResolver().Resolve(source.AsFuzzyLogicNonNumericSequenceValue, reasonOfFuzzyLogicResolving, localCodeExecutionContext, options), _context));
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(sourceKind), sourceKind, null);
            }
        }