예제 #1
0
 public virtual void SetADV(TextScenario scenario)
 {
     foreach (CommandData commandData in this.list.Where <CommandData>((Func <CommandData, bool>)(p => p.isVar)))
     {
         scenario.Vars[commandData.key] = new ValData(ValData.Convert(commandData.value, commandData.value.GetType()));
     }
     this.UpdateReplaceADV(scenario);
 }
예제 #2
0
        public virtual void SetParamSync(TextScenario scenario, string key, object value)
        {
            CommandData commandData = this.list.FirstOrDefault <CommandData>((Func <CommandData, bool>)(p => p.key == key));

            if (commandData == null)
            {
                return;
            }
            ValData valData = new ValData(ValData.Convert(value, commandData.value.GetType()));

            commandData.value = valData.o;
            scenario.Vars[commandData.key] = valData;
            this.UpdateReplaceADV(scenario);
        }
예제 #3
0
        public static object Cast(object o, System.Type type)
        {
            if (o == null)
            {
                return(ValData.Convert(o, type));
            }
            if (type == typeof(int))
            {
                int?nullable = new int?();
                switch (o)
                {
                case int _:
                case float _:
                    nullable = new int?((int)o);
                    break;

                case bool flag:
                    nullable = new int?(!flag ? 0 : 1);
                    break;

                default:
                    int result;
                    if (int.TryParse(o.ToString(), out result))
                    {
                        nullable = new int?(result);
                        break;
                    }
                    break;
                }
                return((object)(!nullable.HasValue ? 0 : nullable.Value));
            }
            if (type == typeof(float))
            {
                float?nullable = new float?();
                if (o is float num)
                {
                    nullable = new float?(num);
                }
                else
                {
                    float result;
                    if (float.TryParse(o.ToString(), out result))
                    {
                        nullable = new float?(result);
                    }
                }
                return((object)(float)(!nullable.HasValue ? 0.0 : (double)nullable.Value));
            }
            if (!(type == typeof(bool)))
            {
                return((object)o.ToString());
            }
            bool?nullable1 = new bool?();

            switch (o)
            {
            case bool flag:
                nullable1 = new bool?(flag);
                break;

            case int _:
            case float _:
                nullable1 = new bool?((int)o > 0);
                break;

            default:
                bool result1;
                if (bool.TryParse(o.ToString(), out result1))
                {
                    nullable1 = new bool?(result1);
                    break;
                }
                break;
            }
            return((object)(bool)(!nullable1.HasValue ? 0 : (nullable1.Value ? 1 : 0)));
        }
예제 #4
0
 public object Convert(object val)
 {
     return(ValData.Convert(val, this.o.GetType()));
 }