コード例 #1
0
        public string GetValue(IContext <string> context)
        {
            if (overridePropFunc != null && overridePropFunc.TryGetValue(propName, out var func))
            {
                return(monad.Lift(func()));
            }

            var finalPropOrMethod = $"({context.Value}.{propName})";

            return(monad.Lift($"(CSharpHelper.IsNumber({finalPropOrMethod}) " +
                              $"? ((double)({finalPropOrMethod})) " +
                              $": ({finalPropOrMethod}))"));
        }
コード例 #2
0
        public TMonad GetValue(IContext <TMonad> context)
        {
            var oc   = context as ObjectContext <TMonad>;
            var type = oc.Object?.GetType();

            if (!propSet || prop?.DeclaringType != type)
            {
                prop    = type?.GetProperty(propName);
                propSet = true;
            }
            return(prop == null
                ? monad.Unit
                : monad.Lift(prop?.GetValue(oc.Object)));
        }
コード例 #3
0
        public string GetValue(IContext <string> context)
        {
            if (overridePropertyFunc != null && overridePropertyFunc.TryGetValue(propName, out var func))
            {
                return(monad.Lift(func()));
            }

            string finalPropOrMethod = propName;

            if (Regex.Match(context.Value, jsDateObjPattern).Success&& jsDatePropertyMethods.TryGetValue(propName, out var jsDateMethod))
            {
                finalPropOrMethod = jsDateMethod;
            }

            if (context.Value.Contains(Constants.DefaultContext))
            {
                return($"{Constants.DefaultContext}.{finalPropOrMethod}");
            }

            return(monad.Lift(context.Value == "{ }"
                ? $"{Constants.DefaultContext}.{finalPropOrMethod}"
                : $"{context.Value}.{finalPropOrMethod}"));
        }
コード例 #4
0
 public ValueExpr(IMonad <TMonad> monad, object value)
 {
     Monad      = monad;
     this.value = Monad.Lift(value);
 }