src/EasyFrameWork/RuleEngine/Scripting/Compiler/EvaluationResult.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System;

namespace Easy.RuleEngine.Scripting.Compiler
{
    public class EvaluationResult
    {
        private readonly object _value;

        public EvaluationResult(object value)
        {
            _value = value;
        }

        public static EvaluationResult Result(object value)
        {
            if (value is EvaluationResult)
                throw new InvalidOperationException("Internal error: value cannot be an evaluation result.");
            return new EvaluationResult(value);
        }

        public static EvaluationResult Error(string message)
        {
            return new EvaluationResult(new Error { Message = message });
        }

        public object Value { get { return _value; } }

        public bool IsError { get { return Value is Error; } }
        public bool IsNil { get { return IsNull; } }
        public bool IsNull { get { return Value == null; } }
        public bool IsBool { get { return Value is bool; } }
        public bool IsInt32 { get { return Value is int; } }
        public bool IsMoney { get { return Value is decimal; } }
        public bool IsString { get { return Value is string; } }
        public bool IsDateTime { get { return Value is DateTime; } }
        public Error ErrorValue { get { return (Error)Value; } }
        public bool BoolValue { get { return (bool)Value; } }
        public int Int32Value { get { return (int)Value; } }
        public decimal MoneyValue { get { return Convert.ToDecimal(Value); } }
        public DateTime DateTimeValue { get { return (DateTime)Value; } }
        public string StringValue { get { return (string)Value; } }

        public override string ToString()
        {
            return IsNull ? "<null>" : Value.ToString();
        }
    }

    public class Error
    {
        public string Message { get; set; }
        public Exception Exception { get; set; }

        public override string ToString()
        {
            return string.Format("Error: {0}", Message);
后面还有 3 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。