Пример #1
0
        public override bool Run()
        {
            List <string> array = new List <string>();

            KScript().ArrayInsert(id, array);

            bool createUsingExisting = !string.IsNullOrEmpty(from);

            if (createUsingExisting)
            {
                string val = HandleCommands(from);

                if (!KScript().ArraysGet().ContainsKey(val))
                {
                    throw new KScriptArrayNotFound(this,
                                                   string.Format("The array '{0}' was not found.", val));
                }

                KScript().ArraysGet()[id] = KScript().ArraysGet()[val];
            }


            try
            {
                if (!string.IsNullOrEmpty(Contents))
                {
                    string split_contents = HandleCommands(Contents);
                    KScriptArraySplitHandler.Split(split_contents, string.IsNullOrEmpty(delimiter) ? "," : delimiter).ForEach(value => KScript().ArrayGet(this, id).Add(value));
                }
            }
            catch (Exception)
            {
                throw new KScriptException("Failture to create array using contents. Ensure values are seperated using ','");
            }

            return(true);
        }
Пример #2
0
 public override string Evaluate(params string[] args)
 {
     try
     {
         KScript().ArrayInsert(GetDef().id, new System.Collections.Generic.List <string>(KScriptArraySplitHandler.Split(GetDef().Contents, ",")));
         return(ToBoolString(true));
     }
     catch
     {
         return(ToBoolString(false));
     }
 }